Overview
Comment: | Migrate OFValueTests to ObjFWTest |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | objfwtest |
Files: | files | file ages | folders |
SHA3-256: |
a14df8d891a0d80a716a6a1711e0b6ab |
User & Date: | js on 2024-02-18 19:13:47 |
Other Links: | branch diff | manifest | tags |
Context
2024-02-18
| ||
19:23 | Migrate OFStreamTests to ObjFWTest check-in: 886a90bb34 user: js tags: objfwtest | |
19:13 | Migrate OFValueTests to ObjFWTest check-in: a14df8d891 user: js tags: objfwtest | |
18:53 | Migrate OFXMLNodeTests to ObjFWTest check-in: fd477d1a54 user: js tags: objfwtest | |
Changes
Modified new_tests/Makefile from [8515f58790] to [114c8fcb6d].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ OFSetTests.m \ OFStringTests.m \ OFSystemInfoTests.m \ OFUTF8StringTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ ${RUNTIME_ARC_TESTS_M} \ RuntimeTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ | > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ OFSetTests.m \ OFStringTests.m \ OFSystemInfoTests.m \ OFUTF8StringTests.m \ OFValueTests.m \ OFXMLElementBuilderTests.m \ OFXMLNodeTests.m \ OFXMLParserTests.m \ ${RUNTIME_ARC_TESTS_M} \ RuntimeTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ |
︙ | ︙ |
Renamed and modified tests/OFValueTests.m [52b7d9b170] to new_tests/OFValueTests.m [200d6d2788].
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #include <string.h> | | > | > | | > > > | > > > > > > > | > > > | > > | | > > > > > > > > > | < < < < < < < < < < < < < < < < | < | | | > | < | > | > | > > | | | | | | < | > | | > > > | < | > | | < < < < < < | > | > | > | | > > > | < | > | | < < < < < < | > | > | > | | > > > | < | > | | < < < | | | < | > | | > > > | < | > | | < < < | | | > | > | > | > | | | | > | < | > | | < < | 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | * file. */ #include "config.h" #include <string.h> #import "ObjFW.h" #import "ObjFWTest.h" @interface OFValueTests: OTTestCase @end @implementation OFValueTests - (void)testObjCType { OFRange range = OFMakeRange(1, 64); OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; OTAssertEqual(strcmp(value.objCType, @encode(OFRange)), 0); } - (void)testGetValueSize { OFRange range = OFMakeRange(1, 64), range2; OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; [value getValue: &range2 size: sizeof(OFRange)]; OTAssert(OFEqualRanges(range2, range)); } - (void)testGetValueSizeThrowsOnWrongSize { OFRange range = OFMakeRange(1, 64); OFValue *value = [OFValue valueWithBytes: &range objCType: @encode(OFRange)]; OTAssertThrowsSpecific( [value getValue: &range size: sizeof(OFRange) - 1], OFOutOfRangeException); } - (void)testPointer { void *pointer = &pointer; OFValue *value = [OFValue valueWithPointer: pointer]; OTAssertEqual(value.pointerValue, pointer); OTAssertEqual([[OFValue valueWithBytes: &pointer objCType: @encode(void *)] pointerValue], pointer); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] pointerValue], OFOutOfRangeException); } - (void)testNonretainedObject { id object = (id)&object; OFValue *value = [OFValue valueWithNonretainedObject: object]; OTAssertEqual(value.nonretainedObjectValue, object); OTAssertEqual([[OFValue valueWithBytes: &object objCType: @encode(id)] nonretainedObjectValue], object); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] nonretainedObjectValue], OFOutOfRangeException); } - (void)testRange { OFRange range = OFMakeRange(1, 64), range2; OFValue *value = [OFValue valueWithRange: range]; OTAssert(OFEqualRanges(value.rangeValue, range)); OTAssert(OFEqualRanges( [[OFValue valueWithBytes: &range objCType: @encode(OFRange)] rangeValue], range)); [value getValue: &range2 size: sizeof(range2)]; OTAssert(OFEqualRanges(range2, range)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] rangeValue], OFOutOfRangeException); } - (void)testPoint { OFPoint point = OFMakePoint(1.5f, 3.0f), point2; OFValue *value = [OFValue valueWithPoint: point]; OTAssert(OFEqualPoints(value.pointValue, point)); OTAssert(OFEqualPoints( [[OFValue valueWithBytes: &point objCType: @encode(OFPoint)] pointValue], point)); [value getValue: &point2 size: sizeof(point2)]; OTAssert(OFEqualPoints(point2, point)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] pointValue], OFOutOfRangeException); } - (void)testSize { OFSize size = OFMakeSize(4.5f, 5.0f), size2; OFValue *value = [OFValue valueWithSize: size]; OTAssert(OFEqualSizes(value.sizeValue, size)); OTAssert(OFEqualSizes( [[OFValue valueWithBytes: &size objCType: @encode(OFSize)] sizeValue], size)); [value getValue: &size2 size: sizeof(size2)]; OTAssert(OFEqualSizes(size2, size)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] sizeValue], OFOutOfRangeException); } - (void)testRect { OFRect rect = OFMakeRect(1.5f, 3.0f, 4.5f, 6.0f), rect2; OFValue *value = [OFValue valueWithRect: rect]; OTAssert(OFEqualRects(value.rectValue, rect)); OTAssert(OFEqualRects( [[OFValue valueWithBytes: &rect objCType: @encode(OFRect)] rectValue], rect)); [value getValue: &rect2 size: sizeof(rect2)]; OTAssert(OFEqualRects(rect2, rect)); OTAssertThrowsSpecific( [[OFValue valueWithBytes: "a" objCType: @encode(char)] rectValue], OFOutOfRangeException); } - (void)testIsEqual { OFRect rect = OFMakeRect(1.5f, 3.0f, 4.5f, 6.0f); OTAssertEqualObjects([OFValue valueWithRect: rect], [OFValue valueWithBytes: &rect objCType: @encode(OFRect)]); OTAssertNotEqualObjects( [OFValue valueWithBytes: "a" objCType: @encode(signed char)], [OFValue valueWithBytes: "a" objCType: @encode(unsigned char)]); OTAssertNotEqualObjects( [OFValue valueWithBytes: "a" objCType: @encode(char)], [OFValue valueWithBytes: "b" objCType: @encode(char)]); } @end |
Modified tests/Makefile from [c7ade39e1a] to [b728fe0fc7].
︙ | ︙ | |||
10 11 12 13 14 15 16 | ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = OFStreamTests.m \ | < | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ${PROG_NOINST}.nro \ ${PROG_NOINST}.rpx DISTCLEAN = Info.plist PROG_NOINST = tests${PROG_SUFFIX} STATIC_LIB_NOINST = ${TESTS_STATIC_LIB} SRCS = OFStreamTests.m \ TestsAppDelegate.m IOS_USER ?= mobile IOS_TMP ?= /tmp/objfw-test include ../buildsys.mk |
︙ | ︙ |
Modified tests/TestsAppDelegate.h from [5a2edc0b1c] to [490f0ea954].
︙ | ︙ | |||
58 59 60 61 62 63 64 | - (void)outputSuccess: (OFString *)test inModule: (OFString *)module; - (void)outputFailure: (OFString *)test inModule: (OFString *)module; @end @interface TestsAppDelegate (OFStreamTests) - (void)streamTests; @end | < < < < | 58 59 60 61 62 63 64 | - (void)outputSuccess: (OFString *)test inModule: (OFString *)module; - (void)outputFailure: (OFString *)test inModule: (OFString *)module; @end @interface TestsAppDelegate (OFStreamTests) - (void)streamTests; @end |
Modified tests/TestsAppDelegate.m from [01900772f3] to [98b6176409].
︙ | ︙ | |||
366 367 368 369 370 371 372 | [OFString stringWithUTF8String: (const char *)resourcesPath]]; #endif #if defined(OF_WII) && defined(OF_HAVE_FILES) [[OFFileManager defaultManager] changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif | < | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | [OFString stringWithUTF8String: (const char *)resourcesPath]]; #endif #if defined(OF_WII) && defined(OF_HAVE_FILES) [[OFFileManager defaultManager] changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif [self streamTests]; [OFStdOut reset]; #if defined(OF_IOS) [OFStdOut writeFormat: @"%d tests failed!", _fails]; [OFApplication terminateWithStatus: _fails]; |
︙ | ︙ |