JsonArrayTests.cpp 692 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "CppUnitTest.h"
  2. #include "JsonArray.h"
  3. using namespace Microsoft::VisualStudio::CppUnitTestFramework;
  4. namespace JsonGeneratorTests
  5. {
  6. TEST_CLASS(JsonArrayTests)
  7. {
  8. JsonArray<32> arr;
  9. public:
  10. TEST_METHOD(EmptyArray)
  11. {
  12. AssertJsonIs("[]");
  13. }
  14. TEST_METHOD(OneString)
  15. {
  16. arr.add("hello");
  17. AssertJsonIs("['hello']");
  18. }
  19. void AssertJsonIs(const char* expected)
  20. {
  21. char buffer[256];
  22. arr.writeTo(buffer, sizeof(buffer));
  23. Assert::AreEqual(expected, buffer);
  24. }
  25. };
  26. }