aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMLoggerRingBufferWriterTest.m
diff options
context:
space:
mode:
authorGravatar dmaclach <dmaclach@google.com>2016-10-07 12:10:23 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-10-07 12:21:06 -0400
commit42124b3691197c3c4f52f069775fa0390a8ff942 (patch)
treeebd373d398ea64b45bdc1d196fa0a2c5f57cabfd /Foundation/GTMLoggerRingBufferWriterTest.m
parent57eeab4193210df8ab0c81e9d3f1ee1ad3e24492 (diff)
First cut at pruning things/updating things.
Remove a bunch of code that Google stopped using/maintaining rather than trying to update it it. Some would be hard to update, some actually has system provided replacements; others are patterns that just don't seem as common now. Prune out the code related to macOS <= 10.5, start pruning some of the really old iOS support also. Get the projects mostly limping again with modern Xcodes so tests can be run. If someone ends up on this commit via history for something they still find as useful, feel free to do a pull request to bring the snippet of code back to life and update it for current SDKs.
Diffstat (limited to 'Foundation/GTMLoggerRingBufferWriterTest.m')
-rw-r--r--Foundation/GTMLoggerRingBufferWriterTest.m123
1 files changed, 61 insertions, 62 deletions
diff --git a/Foundation/GTMLoggerRingBufferWriterTest.m b/Foundation/GTMLoggerRingBufferWriterTest.m
index 1c5d72b..73cc306 100644
--- a/Foundation/GTMLoggerRingBufferWriterTest.m
+++ b/Foundation/GTMLoggerRingBufferWriterTest.m
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -19,7 +19,6 @@
#import "GTMSenTestCase.h"
#import "GTMLoggerRingBufferWriter.h"
#import "GTMLogger.h"
-#import "GTMUnitTestDevLog.h"
// --------------------------------------------------
// CountingWriter keeps a count of the number of times it has been
@@ -87,16 +86,16 @@
line:(int)line {
NSArray *loggedContents = [writer loggedContents];
- STAssertEquals([expected count], [loggedContents count],
+ XCTAssertEqual([expected count], [loggedContents count],
@"count mismatch from line %d", line);
for (unsigned int i = 0; i < [expected count]; i++) {
- STAssertEqualObjects([expected objectAtIndex:i],
- [loggedContents objectAtIndex:i],
- @"logging mistmatch at index %d from line %d",
- i, line);
+ XCTAssertEqualObjects([expected objectAtIndex:i],
+ [loggedContents objectAtIndex:i],
+ @"logging mistmatch at index %d from line %d",
+ i, line);
}
-
+
} // compareWithExpectedLogging
@@ -118,24 +117,24 @@
GTMLoggerRingBufferWriter *writer =
[GTMLoggerRingBufferWriter ringBufferWriterWithCapacity:32
writer:countingWriter_];
- STAssertEquals([writer capacity], (NSUInteger)32, nil);
- STAssertTrue([writer writer] == countingWriter_, nil);
- STAssertEquals([writer count], (NSUInteger)0, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)0, nil);
+ XCTAssertEqual([writer capacity], (NSUInteger)32);
+ XCTAssertTrue([writer writer] == countingWriter_);
+ XCTAssertEqual([writer count], (NSUInteger)0);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)0);
// Try with invalid arguments. Should always get nil back.
writer =
[GTMLoggerRingBufferWriter ringBufferWriterWithCapacity:0
writer:countingWriter_];
- STAssertNil(writer, nil);
+ XCTAssertNil(writer);
writer = [GTMLoggerRingBufferWriter ringBufferWriterWithCapacity:32
writer:nil];
- STAssertNil(writer, nil);
+ XCTAssertNil(writer);
writer = [[GTMLoggerRingBufferWriter alloc] init];
- STAssertNil(writer, nil);
+ XCTAssertNil(writer);
} // testCreation
@@ -145,31 +144,31 @@
[GTMLoggerRingBufferWriter ringBufferWriterWithCapacity:4
writer:countingWriter_];
[logger_ setWriter:writer];
-
+
// Shouldn't do anything if there are no contents.
[writer dumpContents];
- STAssertEquals([writer count], (NSUInteger)0, nil);
- STAssertEquals([countingWriter_ count], (NSUInteger)0, nil);
+ XCTAssertEqual([writer count], (NSUInteger)0);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)0);
// Log a single item. Make sure the counts are accurate.
[logger_ logDebug:@"oop"];
- STAssertEquals([writer count], (NSUInteger)1, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)1, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([countingWriter_ count], (NSUInteger)0, nil);
+ XCTAssertEqual([writer count], (NSUInteger)1);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)1);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)0);
// Log a second item. Also make sure counts are accurate.
[logger_ logDebug:@"ack"];
- STAssertEquals([writer count], (NSUInteger)2, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)2, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([countingWriter_ count], (NSUInteger)0, nil);
+ XCTAssertEqual([writer count], (NSUInteger)2);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)2);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)0);
// Print them, and make sure the countingWriter sees the right stuff.
[writer dumpContents];
- STAssertEquals([countingWriter_ count], (NSUInteger)2, nil);
- STAssertEquals([writer count], (NSUInteger)2, nil); // Should not be zeroed.
- STAssertEquals([writer totalLogged], (NSUInteger)2, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)2);
+ XCTAssertEqual([writer count], (NSUInteger)2); // Should not be zeroed.
+ XCTAssertEqual([writer totalLogged], (NSUInteger)2);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"oop",@"ack", nil]
@@ -179,18 +178,18 @@
// Wipe the slates clean.
[writer reset];
[countingWriter_ reset];
- STAssertEquals([writer count], (NSUInteger)0, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)0, nil);
+ XCTAssertEqual([writer count], (NSUInteger)0);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)0);
// An error log level should print the buffer and empty it.
[logger_ logDebug:@"oop"];
[logger_ logInfo:@"ack"];
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)2, nil);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)2);
[logger_ logError:@"blargh"];
- STAssertEquals([countingWriter_ count], (NSUInteger)3, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)3);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"oop", @"ack",
@@ -204,13 +203,13 @@
[logger_ logDebug:@"oop"];
[logger_ logInfo:@"ack"];
[logger_ logDebug:@"blargh"];
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([writer count], (NSUInteger)3, nil);
- STAssertEquals([writer totalLogged], (NSUInteger)3, nil);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([writer count], (NSUInteger)3);
+ XCTAssertEqual([writer totalLogged], (NSUInteger)3);
[logger_ logAssert:@"ouch"];
- STAssertEquals([countingWriter_ count], (NSUInteger)4, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)4);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"oop", @"ack",
@"blargh", @"ouch", nil]
@@ -223,11 +222,11 @@
[logger_ logDebug:@"oop"];
[logger_ logDebug:@"blargh"];
[logger_ logDebug:@"flong"]; // Fills buffer
- STAssertEquals([writer droppedLogCount], (NSUInteger)0, nil);
- STAssertEquals([writer count], (NSUInteger)4, nil);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)0);
+ XCTAssertEqual([writer count], (NSUInteger)4);
[logger_ logAssert:@"ouch"]; // should drop "ack"
- STAssertEquals([countingWriter_ count], (NSUInteger)4, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)4);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"oop", @"blargh",
@@ -242,11 +241,11 @@
[logger_ logDebug:@"blargh"];
[logger_ logDebug:@"flong"]; // Fills buffer
[logger_ logDebug:@"bloogie"]; // should drop "ack"
- STAssertEquals([writer droppedLogCount], (NSUInteger)1, nil);
- STAssertEquals([writer count], (NSUInteger)4, nil);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)1);
+ XCTAssertEqual([writer count], (NSUInteger)4);
[logger_ logAssert:@"ouch"]; // should drop "oop"
- STAssertEquals([countingWriter_ count], (NSUInteger)4, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)4);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"blargh",
@@ -264,22 +263,22 @@
[logger_ setWriter:writer];
[logger_ logInfo:@"ack"];
- STAssertEquals([countingWriter_ count], (NSUInteger)0, nil);
- STAssertEquals([writer count], (NSUInteger)1, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)0);
+ XCTAssertEqual([writer count], (NSUInteger)1);
[writer dumpContents];
- STAssertEquals([countingWriter_ count], (NSUInteger)1, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)1);
[self compareWriter:countingWriter_
- withExpectedLogging:[NSArray arrayWithObjects:@"ack", nil]
+ withExpectedLogging:[NSArray arrayWithObject:@"ack"]
line:__LINE__];
[logger_ logDebug:@"oop"]; // should drop "ack"
- STAssertEquals([writer count], (NSUInteger)1, nil);
- STAssertEquals([writer droppedLogCount], (NSUInteger)1, nil);
+ XCTAssertEqual([writer count], (NSUInteger)1);
+ XCTAssertEqual([writer droppedLogCount], (NSUInteger)1);
[countingWriter_ reset];
[logger_ logError:@"snoogy"]; // should drop "oop"
- STAssertEquals([countingWriter_ count], (NSUInteger)1, nil);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)1);
[self compareWriter:countingWriter_
withExpectedLogging:[NSArray arrayWithObjects:@"snoogy", nil]
@@ -289,7 +288,7 @@
-// Run 10 threads, all logging through the same logger.
+// Run 10 threads, all logging through the same logger.
static volatile NSUInteger gStoppedThreads = 0; // Total number that have stopped.
@@ -343,15 +342,15 @@ static volatile NSUInteger gStoppedThreads = 0; // Total number that have stoppe
}
// Now make sure we get back what's expected.
- STAssertEquals([writer count], kThreadCount, nil);
- STAssertEquals([countingWriter_ count], (NSUInteger)0, nil); // Nothing should be logged
- STAssertEquals([writer totalLogged], (NSUInteger)420, nil);
+ XCTAssertEqual([writer count], kThreadCount);
+ XCTAssertEqual([countingWriter_ count], (NSUInteger)0); // Nothing should be logged
+ XCTAssertEqual([writer totalLogged], (NSUInteger)420);
[logger_ logError:@"bork"];
- STAssertEquals([countingWriter_ count], kCapacity, nil);
-
+ XCTAssertEqual([countingWriter_ count], kCapacity);
+
NSArray *expected = [NSArray arrayWithObjects:
- @"ack", @"ack", @"ack", @"ack", @"ack",
+ @"ack", @"ack", @"ack", @"ack", @"ack",
@"ack", @"ack", @"ack", @"ack", @"bork",
nil];
[self compareWriter:countingWriter_