ObjFW  Check-in [34e6ff9e0b]

Overview
Comment:Migrate OFInvocationTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 34e6ff9e0bd3e662452174897dca1c127dcae5145fa0ba0a74b062bf5fa8fed1
User & Date: js on 2024-02-11 15:32:15
Other Links: branch diff | manifest | tags
Context
2024-02-11
15:49
Migrate OFMatrix4x4Tests to ObjFWTest check-in: 6d64cca782 user: js tags: objfwtest
15:32
Migrate OFInvocationTests to ObjFWTest check-in: 34e6ff9e0b user: js tags: objfwtest
15:18
Merge trunk into branch "objfwtest" check-in: 39545b8c5d user: js tags: objfwtest
Changes

Modified new_tests/Makefile from [20b30a9bfc] to [2edeeab174].

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16








+







include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = OFCharacterSetTests.m	\
       OFColorTests.m		\
       OFIRITests.m		\
       OFInvocationTests.m	\
       OFMethodSignatureTests.m	\
       OFNumberTests.m		\
       OFPBKDF2Tests.m		\
       OFPropertyListTests.m	\
       OFScryptTests.m		\
       ${USE_SRCS_PLUGINS}
SRCS_PLUGINS = OFPluginTests.m

Renamed and modified tests/OFInvocationTests.m [23f57f7d3a] to new_tests/OFInvocationTests.m [860bceb260].

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
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







-
+
+

+
+
-
+
+
+






-
+


-
-
+
+

-
+


-
+

-

+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
-
-
+
+
+

-
-
-
+
-

-
-
-
-
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
+

-
-
+
+

-
-
+
+

-
-
+
+

-
-
+
-
-
+
-



#include <string.h>

#if defined(HAVE_COMPLEX_H) && !defined(__STDC_NO_COMPLEX__)
# include <complex.h>
#endif

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

@interface OFInvocationTests: OTTestCase
{
static OFString *const module = @"OFInvocation";
	OFInvocation *_invocation;
}
@end

struct TestStruct {
	unsigned char c;
	unsigned int i;
};

@implementation TestsAppDelegate (OFInvocationTests)
@implementation OFInvocationTests
- (struct TestStruct)invocationTestMethod1: (unsigned char)c
					  : (unsigned int)i
					  : (struct TestStruct *)ptr
					  : (struct TestStruct)st
					  : (struct TestStruct *)testStructPtr
					  : (struct TestStruct)testStruct
{
	return st;
	return testStruct;
}

- (void)invocationTests
- (void)setUp
{
	void *pool = objc_autoreleasePoolPush();
	SEL selector = @selector(invocationTestMethod1::::);
	OFMethodSignature *signature =
	OFMethodSignature *sig = [self methodSignatureForSelector: selector];
	OFInvocation *invocation;
	struct TestStruct st, st2, *stp = &st, *stp2;
	    [self methodSignatureForSelector: selector];

	_invocation = [[OFInvocation alloc] initWithMethodSignature: signature];
}

- (void)dealloc
{
	[_invocation release];

	[super dealloc];
}

- (void)testSetAndGetReturnValue
{
	struct TestStruct testStruct, testStruct2;

	memset(&testStruct, 0xFF, sizeof(testStruct));
	testStruct.c = 0x55;
	testStruct.i = 0xAAAAAAAA;

	[_invocation setReturnValue: &testStruct];
	[_invocation getReturnValue: &testStruct2];
	OTAssertEqual(memcmp(&testStruct, &testStruct2, sizeof(testStruct)), 0);
}

- (void)testSetAndGetArgumentAtIndex
{
	struct TestStruct testStruct, testStruct2;
	struct TestStruct *testStructPtr = &testStruct, *testStructPtr2;
	unsigned const char c = 0xAA;
	unsigned char c2;
	const unsigned int i = 0x55555555;
	unsigned int i2;

	memset(&st, '\xFF', sizeof(st));
	st.c = 0x55;
	st.i = 0xAAAAAAAA;
	memset(&testStruct, 0xFF, sizeof(testStruct));
	testStruct.c = 0x55;
	testStruct.i = 0xAAAAAAAA;

	TEST(@"+[invocationWithMethodSignature:]",
	    (invocation = [OFInvocation invocationWithMethodSignature: sig]))

	memset(&testStruct2, 0, sizeof(testStruct2));
	TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st]))

	TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) &&
	    memcmp(&st, &st2, sizeof(st)) == 0)

	memset(&st2, '\0', sizeof(st2));

	TEST(@"-[setArgument:atIndex:] #1",
	    R([invocation setArgument: &c atIndex: 2]))
	[_invocation setArgument: &c atIndex: 2];

	TEST(@"-[setArgument:atIndex:] #2",
	    R([invocation setArgument: &i atIndex: 3]))
	[_invocation setArgument: &i atIndex: 3];

	TEST(@"-[setArgument:atIndex:] #3",
	    R([invocation setArgument: &stp atIndex: 4]))
	[_invocation setArgument: &testStructPtr atIndex: 4];

	TEST(@"-[setArgument:atIndex:] #4",
	    R([invocation setArgument: &st atIndex: 5]))
	[_invocation setArgument: &testStruct atIndex: 5];

	TEST(@"-[getArgument:atIndex:] #1",
	    R([invocation getArgument: &c2 atIndex: 2]) && c == c2)
	[_invocation getArgument: &c2 atIndex: 2];
	OTAssertEqual(c, c2);

	TEST(@"-[getArgument:atIndex:] #2",
	    R([invocation getArgument: &i2 atIndex: 3]) && i == i2)
	[_invocation getArgument: &i2 atIndex: 3];
	OTAssertEqual(i, i2);

	TEST(@"-[getArgument:atIndex:] #3",
	    R([invocation getArgument: &stp2 atIndex: 4]) && stp == stp2)
	[_invocation getArgument: &testStructPtr2 atIndex: 4];
	OTAssertEqual(testStructPtr, testStructPtr2);

	TEST(@"-[getArgument:atIndex:] #4",
	    R([invocation getArgument: &st2 atIndex: 5]) &&
	[_invocation getArgument: &testStruct2 atIndex: 5];
	    memcmp(&st, &st2, sizeof(st)) == 0)

	OTAssertEqual(memcmp(&testStruct, &testStruct2, sizeof(testStruct)), 0);
	objc_autoreleasePoolPop(pool);
}
@end

Modified tests/Makefile from [2c529c8014] to [582d5b4a14].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
20
21
22
23
24
25
26

27
28
29
30
31
32
33







-







       OFArrayTests.m			\
       ${OF_BLOCK_TESTS_M}		\
       OFDataTests.m			\
       OFDateTests.m			\
       OFDictionaryTests.m		\
       OFHMACTests.m			\
       OFINIFileTests.m			\
       OFInvocationTests.m		\
       OFJSONTests.m			\
       OFListTests.m			\
       OFLocaleTests.m			\
       OFMD5HashTests.m			\
       OFMatrix4x4Tests.m		\
       OFMemoryStreamTests.m		\
       OFNotificationCenterTests.m	\

Modified tests/TestsAppDelegate.h from [47814f92cb] to [f8e34fd306].

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
107
108
109
110
111
112
113




114
115
116
117
118
119
120







-
-
-
-







- (void)INIFileTests;
@end

@interface TestsAppDelegate (OFIPXSocketTests)
- (void)IPXSocketTests;
@end

@interface TestsAppDelegate (OFInvocationTests)
- (void)invocationTests;
@end

@interface TestsAppDelegate (OFJSONTests)
- (void)JSONTests;
@end

@interface TestsAppDelegate (OFHMACTests)
- (void)HMACTests;
@end

Modified tests/TestsAppDelegate.m from [76faf80ff2] to [be2555a72f].

371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
371
372
373
374
375
376
377

378
379
380
381
382
383
384







-







#endif

	[self runtimeTests];
#ifdef COMPILER_SUPPORTS_ARC
	[self runtimeARCTests];
#endif
	[self objectTests];
	[self invocationTests];
	[self forwardingTests];
#ifdef OF_HAVE_BLOCKS
	[self blockTests];
#endif
	[self stringTests];
	[self dataTests];
	[self arrayTests];