Skip to content

Commit

Permalink
Merge ff061fc into 889745a
Browse files Browse the repository at this point in the history
  • Loading branch information
bangfalse committed Sep 17, 2020
2 parents 889745a + ff061fc commit c8a73d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/src/query/result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Result {
var result = getValue(index: index, key: key);
if (result is bool) {
return result;
} else if (result is num) {
return result != 0;
} else {
return null;
}
Expand Down
21 changes: 18 additions & 3 deletions test/query_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ void main() {
group("Results", () {
var map = {
"int": 1,
"bool": true,
"true": true,
"false": false,
"1": 1,
"0": 0,
"list": [],
"double": 1.2,
"string": "test",
Expand Down Expand Up @@ -484,8 +487,20 @@ void main() {
expect(newResult.getList(key: "list"), []);
});

test("getBoolean()", () {
expect(newResult.getBoolean(key: "bool"), true);
test("getBoolean(true)", () {
expect(newResult.getBoolean(key: "true"), true);
});

test("getBoolean(false)", () {
expect(newResult.getBoolean(key: "false"), false);
});

test("getBoolean(1)", () {
expect(newResult.getBoolean(key: "1"), true);
});

test("getBoolean(0)", () {
expect(newResult.getBoolean(key: "0"), false);
});

test("getDouble()", () {
Expand Down

0 comments on commit c8a73d8

Please sign in to comment.