Skip to content

Commit b285394

Browse files
committed
fix GetBool in Document
1 parent ee50da5 commit b285394

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/aws-cpp-sdk-core/source/utils/Document.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ bool DocumentView::GetBool(const Aws::String& key) const
449449
assert(m_json);
450450
auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_json, key.c_str());
451451
assert(item);
452-
return item->valueint != 0;
452+
return item->type == cJSON_AS4CPP_True;
453453
}
454454

455455
bool DocumentView::AsBool() const

tests/aws-cpp-sdk-core-tests/utils/DocumentTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,13 @@ TEST_F(DocumentTest, TestEquality)
637637
built.WithString("AWS", "Amazon Web Services");
638638
ASSERT_NE(parsed, built);
639639
}
640+
641+
TEST_F(DocumentTest, TestBooleanTrue)
642+
{
643+
const auto doc = Document{}
644+
.WithBool("time_marches_on", true)
645+
.WithBool("and_the_age_of_a_new_king_draws_near", false);
646+
647+
ASSERT_TRUE(doc.View().GetBool("time_marches_on"));
648+
ASSERT_FALSE(doc.View().GetBool("and_the_age_of_a_new_king_draws_near"));
649+
}

0 commit comments

Comments
 (0)