Differences From Artifact [6b63270541]:
- File tests/OFINIFileTests.m — part of check-in [904d0639c4] at 2024-08-24 09:20:58 on branch trunk — OFINIFile: Allow comments before first category (user: js, size: 5018) [annotate] [blame] [check-ins using] [more...]
To Artifact [0bacd762e4]:
- File
tests/OFINIFileTests.m
— part of check-in
[0fead8a915]
at
2024-08-24 10:14:30
on branch trunk
— Rename OFINICategory to OFINISection
OFINICategory is provided as a deprecated subclass of OFINISection to
maintain API and ABI compatibility. (user: js, size: 4992) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
45 46 47 48 49 50 51 | - (void)dealloc { [_file release]; [super dealloc]; } | | | | | | | | | | | | | | 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 | - (void)dealloc { [_file release]; [super dealloc]; } - (void)testSectionForName { OTAssertNotNil([_file sectionForName: @"tests"]); OTAssertNotNil([_file sectionForName: @"foobar"]); OTAssertNotNil([_file sectionForName: @"types"]); } - (void)testStringValueForKey { OTAssertEqualObjects( [[_file sectionForName: @"tests"] stringValueForKey: @"foo"], @"bar"); OTAssertEqualObjects([[_file sectionForName: @"foobar"] stringValueForKey: @"quxquxqux"], @"hello\"wörld"); } - (void)testLongLongValueForKeyDefaultValue { OTAssertEqual([[_file sectionForName: @"types"] longLongValueForKey: @"integer" defaultValue: 2], 0x20); } - (void)testBoolValueForKeyDefaultValue { OTAssertTrue([[_file sectionForName: @"types"] boolValueForKey: @"bool" defaultValue: false]); } - (void)testFloatValueForKeyDefaultValue { OTAssertEqual([[_file sectionForName: @"types"] floatValueForKey: @"float" defaultValue: 1], 0.5f); } - (void)testDoubleValueForKeyDefaultValue { OTAssertEqual([[_file sectionForName: @"types"] doubleValueForKey: @"double" defaultValue: 3], 0.25); } - (void)testArrayValueForKey { OFINISection *types = [_file sectionForName: @"types"]; OFArray *array = [OFArray arrayWithObjects: @"1", @"2", nil]; OTAssertEqualObjects([types arrayValueForKey: @"array1"], array); OTAssertEqualObjects([types arrayValueForKey: @"array2"], array); OTAssertEqualObjects([types arrayValueForKey: @"array3"], [OFArray array]); } - (void)testWriteToIRIEncoding { OFString *expectedOutput = @"; Comment before sections\r\n" @"\r\n" @"[tests]\r\n" @"foo=baz\r\n" @"foobar=baz\r\n" @";comment\r\n" @"new=new\r\n" @"\r\n" |
︙ | ︙ | |||
129 130 131 132 133 134 135 | @"[types]\r\n" @"integer=16\r\n" @"bool=false\r\n" @"float=0.25\r\n" @"array1=foo\r\n" @"array1=bar\r\n" @"double=0.75\r\n"; | | | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | @"[types]\r\n" @"integer=16\r\n" @"bool=false\r\n" @"float=0.25\r\n" @"array1=foo\r\n" @"array1=bar\r\n" @"double=0.75\r\n"; OFINISection *tests = [_file sectionForName: @"tests"]; OFINISection *foobar = [_file sectionForName: @"foobar"]; OFINISection *types = [_file sectionForName: @"types"]; OFArray *array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; #if defined(OF_HAVE_FILES) && !defined(OF_NINTENDO_DS) OFIRI *writeIRI; #endif [tests setStringValue: @"baz" forKey: @"foo"]; [tests setStringValue: @"new" forKey: @"new"]; |
︙ | ︙ | |||
173 174 175 176 177 178 179 | [[OFFileManager defaultManager] removeItemAtIRI: writeIRI]; } #else (void)expectedOutput; #endif } | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | [[OFFileManager defaultManager] removeItemAtIRI: writeIRI]; } #else (void)expectedOutput; #endif } - (void)testPairOutsideOfSectionRejected { OFIRI *IRI = [OFIRI IRIWithString: @"embedded:testfile_broken.ini"]; OFRegisterEmbeddedFile(@"testfile_broken.ini", (const uint8_t *)"; comment\r\na=b", 14); OTAssertThrowsSpecific([OFINIFile fileWithIRI: IRI], OFInvalidFormatException); } @end |