-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryTests.cpp
More file actions
54 lines (37 loc) · 1.21 KB
/
LibraryTests.cpp
File metadata and controls
54 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "gtest/gtest.h"
#include <fstream>
#include <string>
#include <iostream>
#include "Archive.h"
const std::string inputFile = "data/SpainSchool.xml";
inline bool exists(const std::string& name)
{
return (static_cast<bool>(std::ifstream(name)));
}
TEST(HandleInstance, InstanceFileExists){
EXPECT_TRUE(exists(inputFile));
}
TEST(HandleInstance, CanReadInstance){
Archive arc(inputFile);
Instance inst = arc.getInstance("ES-SS-08");
EXPECT_EQ(inst.getId(), "ES-SS-08");
auto meta = inst.getMeta();
EXPECT_EQ("Spanish school", meta.getName());
EXPECT_EQ(meta.getDate(), "March 7, 2012");
//Test iterator (will throw exception on failure)
for(auto t: inst.getTimes())
t.getId();
}
TEST(HandleInstance, CanWriteInstance){
InstanceMetaData meta("testInst");
Instance inst("testInstance", meta);
Time time1(inst, "Time1", "Time1", false);
Time time2(inst, "Time2", "Time2", false);
ResourceType resType(inst, "resT", "restT");
Resource t(resType, "res1", "res1");
inst.end(false);
Archive arc("archiveID", ArchiveMetaData());
arc.add(inst);
FILE *f = fopen("data/testWriteOut", "w");
arc.write(false, f);
}