blob: 1072f889d3bea2a6c61fe4055d20cb222572ece0 [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003//
Joshua Haberman200c9582023-09-08 17:42:37 -07004// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
Thomas Van Lenten30650d82015-05-01 08:57:16 -04007
8#import <XCTest/XCTest.h>
9
10@class TestAllExtensions;
11@class TestAllTypes;
12@class TestMap;
13@class TestPackedTypes;
14@class TestPackedExtensions;
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040015@class TestUnpackedTypes;
16@class TestUnpackedExtensions;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040017@class GPBExtensionRegistry;
18
Sergio Campamab1f954e2017-10-05 17:47:22 -040019static inline NSData *DataFromCStr(const char *str) {
20 return [NSData dataWithBytes:str length:strlen(str)];
21}
Thomas Van Lenten1dcc3292015-05-21 17:14:52 -040022
23// Helper for uses of C arrays in tests cases.
24#ifndef GPBARRAYSIZE
25#define GPBARRAYSIZE(a) ((sizeof(a) / sizeof((a[0]))))
26#endif // GPBARRAYSIZE
27
Thomas Van Lenten30650d82015-05-01 08:57:16 -040028// The number of repetitions of any repeated objects inside of test messages.
29extern const uint32_t kGPBDefaultRepeatCount;
30
31@interface GPBTestCase : XCTestCase
32
33- (void)setAllFields:(TestAllTypes *)message repeatedCount:(uint32_t)count;
34- (void)clearAllFields:(TestAllTypes *)message;
Thomas Van Lentenecd63bb2022-09-19 17:22:33 -040035- (void)setAllExtensions:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
36- (void)setPackedFields:(TestPackedTypes *)message repeatedCount:(uint32_t)count;
37- (void)setUnpackedFields:(TestUnpackedTypes *)message repeatedCount:(uint32_t)count;
38- (void)setPackedExtensions:(TestPackedExtensions *)message repeatedCount:(uint32_t)count;
39- (void)setUnpackedExtensions:(TestUnpackedExtensions *)message repeatedCount:(uint32_t)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040040- (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count;
41
42- (TestAllTypes *)allSetRepeatedCount:(uint32_t)count;
43- (TestAllExtensions *)allExtensionsSetRepeatedCount:(uint32_t)count;
44- (TestPackedTypes *)packedSetRepeatedCount:(uint32_t)count;
45- (TestPackedExtensions *)packedExtensionsSetRepeatedCount:(uint32_t)count;
46
Thomas Van Lentenecd63bb2022-09-19 17:22:33 -040047- (void)assertAllFieldsSet:(TestAllTypes *)message repeatedCount:(uint32_t)count;
48- (void)assertAllExtensionsSet:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
49- (void)assertRepeatedFieldsModified:(TestAllTypes *)message repeatedCount:(uint32_t)count;
50- (void)assertRepeatedExtensionsModified:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040051- (void)assertExtensionsClear:(TestAllExtensions *)message;
52- (void)assertClear:(TestAllTypes *)message;
Thomas Van Lentenecd63bb2022-09-19 17:22:33 -040053- (void)assertPackedFieldsSet:(TestPackedTypes *)message repeatedCount:(uint32_t)count;
54- (void)assertPackedExtensionsSet:(TestPackedExtensions *)message repeatedCount:(uint32_t)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040055
56- (void)modifyRepeatedExtensions:(TestAllExtensions *)message;
57- (void)modifyRepeatedFields:(TestAllTypes *)message;
58
59- (GPBExtensionRegistry *)extensionRegistry;
60
61- (NSData *)getDataFileNamed:(NSString *)name dataToWrite:(NSData *)dataToWrite;
62
63- (void)assertAllFieldsKVCMatch:(TestAllTypes *)message;
Thomas Van Lentenecd63bb2022-09-19 17:22:33 -040064- (void)setAllFieldsViaKVC:(TestAllTypes *)message repeatedCount:(uint32_t)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -040065- (void)assertClearKVC:(TestAllTypes *)message;
66
67@end