-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for flat dictionary, fix dictionaryLiteral (#182)
- Loading branch information
1 parent
5cdb391
commit f38a3ab
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Hummingbird server framework project | ||
// | ||
// Copyright (c) 2023 the Hummingbird authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Hummingbird | ||
import XCTest | ||
|
||
class FlatDictionaryTests: XCTestCase { | ||
func testLiteralInit() { | ||
let a: FlatDictionary<String, String> = ["test": "value", "key2": "value2"] | ||
XCTAssertEqual(a["test"], "value") | ||
XCTAssertEqual(a["key2"], "value2") | ||
} | ||
|
||
func testKeyGetSet() { | ||
var a: FlatDictionary<String, String> = [:] | ||
a["key"] = "value" | ||
XCTAssertEqual(a["key"], "value") | ||
a["key"] = nil | ||
XCTAssertEqual(a["key2"], nil) | ||
} | ||
|
||
func testKeyGetFirst() { | ||
var a: FlatDictionary<String, String> = [:] | ||
a.append(key: "key", value: "value1") | ||
a.append(key: "key", value: "value2") | ||
XCTAssertEqual(a["key"], "value1") | ||
} | ||
} |