Skip to content

Commit e853055

Browse files
added doctests,added getters for testing
1 parent dfa3bac commit e853055

26 files changed

+4698
-4426
lines changed

BookStore.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ void BookStore::saveBooks(std::ofstream& out)
383383
}
384384
}
385385

386+
Book& BookStore::operator[](const size_t index) const
387+
{
388+
return this->books[index];
389+
}
390+
386391
void BookStore::clear()
387392
{
388393
BookStore clean;

BookStore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class BookStore
2222

2323
void loadBooks(std::ifstream&,size_t);
2424
void saveBooks(std::ofstream&);
25+
26+
Book& operator[](const size_t) const; // just for testing
2527
private:
2628
Vector<Book> books;
2729
size_t total;

BookStoreTestLoad.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
4
2+
MyFirstBook
3+
iAmTheAuthor
4+
sci-fi
5+
A cool book about space
6+
4
7+
space
8+
war
9+
planets
10+
stars
11+
2021
12+
100
13+
1
14+
J
15+
a
16+
c
17+
c
18+
3
19+
a
20+
b
21+
c
22+
2020
23+
5
24+
2
25+
A
26+
b
27+
c
28+
c
29+
1
30+
c
31+
2019
32+
4
33+
3
34+
Q
35+
a
36+
a
37+
a
38+
2
39+
a
40+
b
41+
222
42+
3
43+
4

BookTestLoad.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Book
2+
Author
3+
Genre
4+
Summary
5+
1
6+
Tag
7+
2020
8+
100
9+
1

CommandMenu.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "CommandMenu.h"
2-
#include "Library.h"
32
#include <iostream>
43
#include <cstring>
54

@@ -327,6 +326,21 @@ void CommandMenu::getParameters()
327326
parameters.pushBack(parameter);
328327
}
329328

329+
void CommandMenu::setCommand(const String& _command)
330+
{
331+
this->command = _command;
332+
}
333+
334+
Vector<String>& CommandMenu::getTheCommand()
335+
{
336+
return this->theCommand;
337+
}
338+
339+
Vector<String>& CommandMenu::getTheParameters()
340+
{
341+
return this->parameters;
342+
}
343+
330344
void CommandMenu::checkSecondCommand(const String& command)
331345
{
332346
if (command != "info" && command != "find" && command != "sort" && command != "add" && command != "remove" && command != "all" && command != "as")

CommandMenu.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22
#include "Vector.h"
33
#include "String.h"
4-
#include "UserStore.h"
5-
#include "BookStore.h"
4+
#include "Library.h"
65

76
class CommandMenu
87
{
@@ -13,6 +12,10 @@ class CommandMenu
1312
void checkSecondCommand(const String&);
1413
void checkCommand(const String&,const String&,const Vector<String>&);
1514
void getParameters();
15+
16+
void setCommand(const String&); // just for testing
17+
Vector<String>& getTheCommand(); // just for testing
18+
Vector<String>& getTheParameters(); // just for testing
1619
private:
1720
Vector<String> allCommands;
1821
Vector<String> theCommand;

Debug/BookStore.obj

673 Bytes
Binary file not shown.

Debug/CommandMenu.obj

1.99 KB
Binary file not shown.

Debug/Library.log

Lines changed: 131 additions & 6 deletions
Large diffs are not rendered by default.

Debug/Library.obj

12 Bytes
Binary file not shown.

Debug/Library.tlog/CL.command.1.tlog

0 Bytes
Binary file not shown.

Debug/Library.tlog/CL.read.1.tlog

18.4 KB
Binary file not shown.

Debug/Library.tlog/CL.write.1.tlog

744 Bytes
Binary file not shown.

Debug/Library.tlog/link.read.1.tlog

-236 Bytes
Binary file not shown.

Debug/Project.obj

2.42 MB
Binary file not shown.

Debug/String.obj

0 Bytes
Binary file not shown.

Debug/vc142.idb

48 KB
Binary file not shown.

Debug/vc142.pdb

584 KB
Binary file not shown.

0 commit comments

Comments
 (0)