damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit c8e236b6d557e1d45f174d0e5235c6ee54566afc
parent e8d0f1db8dbe17edaf2496da30ae4245158ce527
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 23 Jul 2023 12:21:36 -0700

ndb/test: add more test coverage on char iter

Diffstat:
Mnostrdb/Test/NdbTests.swift | 31+++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/nostrdb/Test/NdbTests.swift b/nostrdb/Test/NdbTests.swift @@ -80,20 +80,31 @@ final class NdbTests: XCTestCase { return } - var count = 0 - var char_count = 0 - for tag in note.tags() { - for elem in tag { - print("iter_elem \(elem.string())") - for _ in elem { - char_count += 1 + + self.measure { + var count = 0 + var char_count = 0 + + for tag in note.tags() { + for elem in tag { + print("iter_elem \(elem.string())") + for c in elem { + if char_count == 0 { + let ac = AsciiCharacter(c) + XCTAssertEqual(ac, "p") + } else if char_count == 0 { + XCTAssertEqual(c, 0x6c) + } + char_count += 1 + } } + count += 1 } - count += 1 + + XCTAssertEqual(count, 786) + XCTAssertEqual(char_count, 24370) } - XCTAssertEqual(count, 786) - XCTAssertEqual(char_count, 24370) } }