ObjFW  Check-in [5bc1402377]

Overview
Comment:Migrate OFASN1DERRepresentationTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | asn1
Files: files | file ages | folders
SHA3-256: 5bc14023773a8e71ab50dbebde23a12a76a01091e7cb54f1b5ac6f353e86ce31
User & Date: js on 2024-02-11 23:56:52
Other Links: branch diff | manifest | tags
Context
2024-02-18
21:07
Merge trunk into branch "asn1" Leaf check-in: 1779d5b5a7 user: js tags: asn1
2024-02-11
23:56
Migrate OFASN1DERRepresentationTests to ObjFWTest check-in: 5bc1402377 user: js tags: asn1
23:48
Migrate OFASN1DERParsingTests to ObjFWTest check-in: 26368c00c5 user: js tags: asn1
Changes

Modified new_tests/Makefile from [6424dba484] to [8d253bc11b].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
	${PROG_NOINST}.nro	\
	${PROG_NOINST}.rpx	\
	testfile_bin.m		\
	testfile_ini.m

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = OFASN1DERParsingTests.m		\

       OFArrayTests.m			\
       OFCharacterSetTests.m		\
       OFColorTests.m			\
       OFConcreteArrayTests.m		\
       OFConcreteMutableArrayTests.m	\
       OFCryptographicHashTests.m	\
       OFDateTests.m			\







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	${PROG_NOINST}.nro	\
	${PROG_NOINST}.rpx	\
	testfile_bin.m		\
	testfile_ini.m

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = OFASN1DERParsingTests.m		\
       OFASN1DERRepresentationTests.m	\
       OFArrayTests.m			\
       OFCharacterSetTests.m		\
       OFColorTests.m			\
       OFConcreteArrayTests.m		\
       OFConcreteMutableArrayTests.m	\
       OFCryptographicHashTests.m	\
       OFDateTests.m			\

Renamed and modified tests/OFASN1DERRepresentationTests.m [40dae6ed10] to new_tests/OFASN1DERRepresentationTests.m [43484abb98].

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
55
56
57
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"


static OFString *module;



@implementation TestsAppDelegate (OFASN1DERRepresentationTests)
- (void)ASN1DERRepresentationTests
{
	void *pool = objc_autoreleasePoolPush();
	OFData *data;

	module = @"OFASN1BitString";
	TEST(@"-[ASN1DERRepresentation]",
	    (data = [OFData dataWithItems: "\xFF\x00\xF8" count: 3]) &&

	    [[[OFASN1BitString bitStringWithBitString: data length: 21]
	    ASN1DERRepresentation] isEqual:
	    [OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8" count: 6]] &&

	    (data = [OFData dataWithItems: "abcdefäöü" count: 12]) &&

	    [[[OFASN1BitString bitStringWithBitString: data length: 12 * 8]
	    ASN1DERRepresentation] isEqual:
	    [OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü" count: 15]] &&
	    (data = [OFData dataWithItems: "" count: 0]) &&

	    [[[OFASN1BitString bitStringWithBitString: data length: 0]
	    ASN1DERRepresentation] isEqual:
	    [OFData dataWithItems: "\x03\x01\x00" count: 3]])

	module = @"OFNumber";
	TEST(@"-[ASN1DERRepresentation] for bool",



	    [[[OFNumber numberWithBool: false] ASN1DERRepresentation]
	    isEqual: [OFData dataWithItems: "\x01\x01\x00" count: 3]] &&


	    [[[OFNumber numberWithBool: true] ASN1DERRepresentation]
	    isEqual: [OFData dataWithItems: "\x01\x01\xFF" count: 3]])

	module = @"OFNull";
	TEST(@"-[OFASN1DERRepresentation]",


	    [[[OFNull null] ASN1DERRepresentation] isEqual:
	    [OFData dataWithItems: "\x05\x00" count: 2]])

	objc_autoreleasePoolPop(pool);
}
@end







|
>

<
>
>

|
|

<


<
<
|
>
|
|
|
>
|
>
|
|
|
|
>
|
|
|
|
|
<
>
>
>
|
|
>
>
|
|
|
|
<
>
>
|
|
|
<
<

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
55
56
57

58
59
60
61
62


63
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "ObjFW.h"
#import "ObjFWTest.h"


@interface OFASN1DERRepresentationTests: OTTestCase
@end

@implementation OFASN1DERRepresentationTests
- (void)testBitString
{

	OFData *data;



	data = [OFData dataWithItems: "\xFF\x00\xF8" count: 3];
	OTAssertEqualObjects([[OFASN1BitString
	    bitStringWithBitString: data
			    length: 21] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x03\x04\x03\xFF\x00\xF8" count: 6]);

	data = [OFData dataWithItems: "abcdefäöü" count: 12];
	OTAssertEqualObjects([[OFASN1BitString
	    bitStringWithBitString: data
			    length: 12 * 8] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x03\x0D\x00" "abcdefäöü" count: 15]);

	OTAssertEqualObjects([[OFASN1BitString
	    bitStringWithBitString: [OFData data]
			    length: 0] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x03\x01\x00" count: 3]);
}


- (void)testInteger
{
	OTAssertEqualObjects(
	    [[OFNumber numberWithBool: false] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x01\x01\x00" count: 3]);

	OTAssertEqualObjects(
	    [[OFNumber numberWithBool: true] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x01\x01\xFF" count: 3]);
}


- (void)testNull
{
	OTAssertEqualObjects([[OFNull null] ASN1DERRepresentation],
	    [OFData dataWithItems: "\x05\x00" count: 2]);
}


@end

Modified tests/Makefile from [21f0912cc1] to [f359c6f71f].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	${PROG_NOINST}.nro	\
	${PROG_NOINST}.rpx
DISTCLEAN = Info.plist

PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = ForwardingTests.m		\
       OFASN1DERRepresentationTests.m	\
       ${OF_BLOCK_TESTS_M}		\
       OFDataTests.m			\
       OFDictionaryTests.m		\
       OFListTests.m			\
       OFLocaleTests.m			\
       OFMemoryStreamTests.m		\
       OFNotificationCenterTests.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 = ForwardingTests.m		\

       ${OF_BLOCK_TESTS_M}		\
       OFDataTests.m			\
       OFDictionaryTests.m		\
       OFListTests.m			\
       OFLocaleTests.m			\
       OFMemoryStreamTests.m		\
       OFNotificationCenterTests.m	\

Modified tests/TestsAppDelegate.h from [fab42aa08a] to [6640fe2961].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
}

- (void)outputTesting: (OFString *)test inModule: (OFString *)module;
- (void)outputSuccess: (OFString *)test inModule: (OFString *)module;
- (void)outputFailure: (OFString *)test inModule: (OFString *)module;
@end

@interface TestsAppDelegate (OFASN1DERRepresentationTests)
- (void)ASN1DERRepresentationTests;
@end

@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;
@end

@interface TestsAppDelegate (OFDDPSocketTests)
- (void)DDPSocketTests;
@end







<
<
<
<







55
56
57
58
59
60
61




62
63
64
65
66
67
68
}

- (void)outputTesting: (OFString *)test inModule: (OFString *)module;
- (void)outputSuccess: (OFString *)test inModule: (OFString *)module;
- (void)outputFailure: (OFString *)test inModule: (OFString *)module;
@end





@interface TestsAppDelegate (OFBlockTests)
- (void)blockTests;
@end

@interface TestsAppDelegate (OFDDPSocketTests)
- (void)DDPSocketTests;
@end

Modified tests/TestsAppDelegate.m from [9268945de9] to [283f0286c6].

411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
#ifdef OF_HAVE_SOCKETS
	[self HTTPCookieTests];
	[self HTTPCookieManagerTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];
	[self XMLElementBuilderTests];
	[self ASN1DERRepresentationTests];

#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif

#ifdef OF_HAVE_SOCKETS
	[self DNSResolverTests];







<







411
412
413
414
415
416
417

418
419
420
421
422
423
424
#ifdef OF_HAVE_SOCKETS
	[self HTTPCookieTests];
	[self HTTPCookieManagerTests];
#endif
	[self XMLParserTests];
	[self XMLNodeTests];
	[self XMLElementBuilderTests];


#ifdef OF_WINDOWS
	[self windowsRegistryKeyTests];
#endif

#ifdef OF_HAVE_SOCKETS
	[self DNSResolverTests];