|
@@ -38,26 +38,69 @@ namespace {
|
38
|
38
|
file.write(reinterpret_cast<char *>(&f2), sizeof(f2));
|
39
|
39
|
}
|
40
|
40
|
|
41
|
|
- //! \fixme Don't use assert(), as it will prevent removing the created test file!
|
42
|
41
|
int test(const char *name) {
|
43
|
42
|
BinaryFile file;
|
44
|
|
- assertEqual(file.open(name), 0);
|
|
43
|
+ if (file.open(name) != 0) {
|
|
44
|
+ std::cout << "Error opening file " << name << std::endl;
|
|
45
|
+ return 1;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ if (file.readU8() != 255) {
|
|
49
|
+ std::cout << "Error reading U8!" << std::endl;
|
|
50
|
+ return 2;
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ if (file.readU16() != 65535) {
|
|
54
|
+ std::cout << "Error reading U16!" << std::endl;
|
|
55
|
+ return 3;
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ if (file.readU32() != 707406378) {
|
|
59
|
+ std::cout << "Error reading U32!" << std::endl;
|
|
60
|
+ return 4;
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ if (file.readU64() != 1099511627775) {
|
|
64
|
+ std::cout << "Error reading U64!" << std::endl;
|
|
65
|
+ return 5;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ if (file.read8() != -1) {
|
|
69
|
+ std::cout << "Error reading 8!" << std::endl;
|
|
70
|
+ return 6;
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ if (file.read16() != -420) {
|
|
74
|
+ std::cout << "Error reading 16!" << std::endl;
|
|
75
|
+ return 7;
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ if (file.read32() != -666) {
|
|
79
|
+ std::cout << "Error reading 32!" << std::endl;
|
|
80
|
+ return 8;
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ if (file.read64() != 4774451407313060418) {
|
|
84
|
+ std::cout << "Error reading 64!" << std::endl;
|
|
85
|
+ return 9;
|
|
86
|
+ }
|
45
|
87
|
|
46
|
|
- assertEqual(file.readU8(), 255);
|
47
|
|
- assertEqual(file.readU16(), 65535);
|
48
|
|
- assertEqual(file.readU32(), 707406378);
|
49
|
|
- assertEqual(file.readU64(), 1099511627775);
|
|
88
|
+ std::cout << "This test will fail on big-endian machines!" << std::endl;
|
50
|
89
|
|
51
|
|
- assertEqual(file.read8(), -1);
|
52
|
|
- assertEqual(file.read16(), -420);
|
53
|
|
- assertEqual(file.read32(), -666);
|
54
|
|
- assertEqual(file.read64(), 4774451407313060418);
|
|
90
|
+ if (file.readFloat() != f1) {
|
|
91
|
+ std::cout << "Error reading float1!" << std::endl;
|
|
92
|
+ return 10;
|
|
93
|
+ }
|
55
|
94
|
|
56
|
|
- std::cout << "This test will fail on big-endian machines!" << std::endl;
|
57
|
|
- assertEqual(file.readFloat(), f1);
|
58
|
|
- assertEqual(file.readFloat(), f2);
|
|
95
|
+ if (file.readFloat() != f2) {
|
|
96
|
+ std::cout << "Error reading float2!" << std::endl;
|
|
97
|
+ return 11;
|
|
98
|
+ }
|
59
|
99
|
|
60
|
|
- assertEqual(file.tell(), 38);
|
|
100
|
+ if (file.tell() != 38) {
|
|
101
|
+ std::cout << "Error, file position wrong!" << std::endl;
|
|
102
|
+ return 12;
|
|
103
|
+ }
|
61
|
104
|
|
62
|
105
|
return 0;
|
63
|
106
|
}
|