Overview
| Comment: | Migrate OFMemoryStreamTests to ObjFWTest |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | objfwtest |
| Files: | files | file ages | folders |
| SHA3-256: |
814d957cdc7e093053c15ee218cb6e9d |
| User & Date: | js on 2024-02-18 17:56:31 |
| Other Links: | branch diff | manifest | tags |
Context
|
2024-02-18
| ||
| 18:27 | Migrate OFXMLParserTests to ObjFWTest (check-in: cd1532bb40 user: js tags: objfwtest) | |
| 17:56 | Migrate OFMemoryStreamTests to ObjFWTest (check-in: 814d957cdc user: js tags: objfwtest) | |
| 17:44 | Migrate OFDataTests to ObjFWTest (check-in: f3bfdcf17a user: js tags: objfwtest) | |
Changes
Modified new_tests/Makefile from [a32f707fdb] to [cd9494fed3].
| ︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
OFINIFileTests.m \
OFIRITests.m \
OFInvocationTests.m \
OFJSONTests.m \
OFListTests.m \
OFLocaleTests.m \
OFMatrix4x4Tests.m \
OFMethodSignatureTests.m \
OFMutableArrayTests.m \
OFMutableDataTests.m \
OFMutableDictionaryTests.m \
OFMutableSetTests.m \
OFMutableStringTests.m \
OFMutableUTF8StringTests.m \
| > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
OFINIFileTests.m \
OFIRITests.m \
OFInvocationTests.m \
OFJSONTests.m \
OFListTests.m \
OFLocaleTests.m \
OFMatrix4x4Tests.m \
OFMemoryStreamTests.m \
OFMethodSignatureTests.m \
OFMutableArrayTests.m \
OFMutableDataTests.m \
OFMutableDictionaryTests.m \
OFMutableSetTests.m \
OFMutableStringTests.m \
OFMutableUTF8StringTests.m \
|
| ︙ | ︙ |
Renamed and modified tests/OFMemoryStreamTests.m [8479ce3790] to new_tests/OFMemoryStreamTests.m [be569a5484].
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | * 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" | | > > > | | | < | < < < < | | > < | | | | | | < | < | > | > | | | | > | | | | | | | > > > | > > | | | | | | < < | | < < | < < | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
* 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 OFMemoryStreamTests: OTTestCase
@end
static const char string[] = "abcdefghijkl";
@implementation OFMemoryStreamTests
- (void)testReadOnlyMemoryStream
{
OFMemoryStream *stream = [OFMemoryStream
streamWithMemoryAddress: (char *)string
size: sizeof(string)
writable: false];
char buffer[10];
/*
* Test the lowlevel methods, as otherwise OFStream will do one big
* read and we will not test OFMemoryStream.
*/
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 5], 5);
OTAssertEqual(memcmp(buffer, "abcde", 5), 0);
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 3], 3);
OTAssertEqual(memcmp(buffer, "fgh", 3), 0);
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 5);
OTAssertEqual(memcmp(buffer, "ijkl", 5), 0);
OTAssertTrue([stream lowlevelIsAtEndOfStream]);
OTAssertEqual([stream lowlevelSeekToOffset: 0 whence: OFSeekCurrent],
sizeof(string));
OTAssertTrue([stream lowlevelIsAtEndOfStream]);
OTAssertEqual([stream lowlevelSeekToOffset: 4 whence: OFSeekSet], 4);
OTAssertFalse([stream lowlevelIsAtEndOfStream]);
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 9);
OTAssertEqual(memcmp(buffer, "efghijkl", 9), 0);
OTAssertEqual([stream lowlevelSeekToOffset: -2 whence: OFSeekEnd], 11);
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 2);
OTAssertEqual(memcmp(buffer, "l", 2), 0);
OTAssertEqual([stream lowlevelReadIntoBuffer: buffer length: 10], 0);
OTAssertThrowsSpecific([stream lowlevelWriteBuffer: "" length: 1],
OFWriteFailedException);
}
- (void)testReadWriteMemoryStream
{
OFMutableData *data = [OFMutableData dataWithCapacity: 13];
OFMemoryStream *stream;
[data increaseCountBy: 13];
stream = [OFMemoryStream streamWithMemoryAddress: data.mutableItems
size: data.count
writable: true];
OTAssertEqual([stream lowlevelWriteBuffer: "abcde" length: 5], 5);
OTAssertEqual([stream lowlevelWriteBuffer: "fgh" length: 3], 3);
OTAssertEqual([stream lowlevelWriteBuffer: "ijkl" length: 5], 5);
OTAssertEqual(memcmp(data.items, string, data.count), 0);
OTAssertEqual([stream lowlevelSeekToOffset: -3 whence: OFSeekEnd], 10);
OTAssertThrowsSpecific([stream lowlevelWriteBuffer: "xyz" length: 4],
OFWriteFailedException);
}
@end
|
Modified tests/Makefile from [6ddbfcb2e3] to [48c72a53ef].
| ︙ | ︙ | |||
9 10 11 12 13 14 15 |
${PROG_NOINST}.nds \
${PROG_NOINST}.nro \
${PROG_NOINST}.rpx
DISTCLEAN = Info.plist
PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
| < | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
${PROG_NOINST}.nds \
${PROG_NOINST}.nro \
${PROG_NOINST}.rpx
DISTCLEAN = Info.plist
PROG_NOINST = tests${PROG_SUFFIX}
STATIC_LIB_NOINST = ${TESTS_STATIC_LIB}
SRCS = OFStreamTests.m \
OFValueTests.m \
OFXMLNodeTests.m \
OFXMLParserTests.m \
TestsAppDelegate.m
IOS_USER ?= mobile
IOS_TMP ?= /tmp/objfw-test
|
| ︙ | ︙ |
Modified tests/TestsAppDelegate.h from [28928cdd08] to [91fcd8efb4].
| ︙ | ︙ | |||
55 56 57 58 59 60 61 | } - (void)outputTesting: (OFString *)test inModule: (OFString *)module; - (void)outputSuccess: (OFString *)test inModule: (OFString *)module; - (void)outputFailure: (OFString *)test inModule: (OFString *)module; @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 (OFStreamTests) - (void)streamTests; @end @interface TestsAppDelegate (OFValueTests) - (void)valueTests; @end |
| ︙ | ︙ |
Modified tests/TestsAppDelegate.m from [b4ea34d386] to [fdc6390186].
| ︙ | ︙ | |||
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 380 381 | [OFString stringWithUTF8String: (const char *)resourcesPath]]; #endif #if defined(OF_WII) && defined(OF_HAVE_FILES) [[OFFileManager defaultManager] changeCurrentDirectoryPath: @"/apps/objfw-tests"]; #endif [self valueTests]; [self streamTests]; [self XMLParserTests]; [self XMLNodeTests]; [OFStdOut reset]; #if defined(OF_IOS) [OFStdOut writeFormat: @"%d tests failed!", _fails]; |
| ︙ | ︙ |