<commit_before>#include "dsa/variant.h"
#include "gtest/gtest.h"

using namespace dsa;

TEST(VariantTest, JsonEncodingInt) {
  Var v(123);

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":123}", encoded_value);
}

TEST(VariantTest, JsonEncodingDouble) {
  Var v(1.23);

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":1.23}", encoded_value);
}

TEST(VariantTest, JsonEncodingBool) {
  {
    Var v(true);

    string_ encoded_value = v.to_json();

    EXPECT_EQ("{\"\":true}", encoded_value);
  }
  {
    Var v(false);

    string_ encoded_value = v.to_json();

    EXPECT_EQ("{\"\":false}", encoded_value);
  }
}

TEST(VariantTest, JsonEncodingString) {
  Var v("hello");

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":\"hello\"}", encoded_value);
}

TEST(VariantTest, JsonEncodingNull) {
  Var v;

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":null}", encoded_value);
}

TEST(VariantTest, JsonEncodingArray) {
  Var v{Var("hello"), Var(123), Var(true)};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":[\"hello\",123,true]}", encoded_value);
}

TEST(VariantTest, JsonEncodingMap) {
  Var v{{"string", Var("hello")},
            {"int", Var(123)},
            {"bool", Var(true)}};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":{\"bool\":true,\"int\":123,\"string\":\"hello\"}}", encoded_value);
}

TEST(VariantTest, JsonEncodingNestedArray) {
  Var v{{"string", Var("hello")},
            {"int", Var(123)},
            {"map", {{"first", Var("one")}, {"second", Var("two")}}}};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"\":{\"int\":123,\"map\":{\"first\":\"one\",\"second\":\"two\"},\"string\":\"hello\"}}", encoded_value);
}

<commit_msg>update json related unit tests<commit_after>#include "dsa/variant.h"
#include "gtest/gtest.h"

using namespace dsa;

TEST(VariantTest, JsonEncodingInt) {
  Var v(123);

  string_ encoded_value = v.to_json();

  EXPECT_EQ("123", encoded_value);
}

TEST(VariantTest, JsonEncodingDouble) {
  Var v(1.23);

  string_ encoded_value = v.to_json();

  EXPECT_EQ("1.23", encoded_value);
}

TEST(VariantTest, JsonEncodingBool) {
  {
    Var v(true);

    string_ encoded_value = v.to_json();

    EXPECT_EQ("true", encoded_value);
  }
  {
    Var v(false);

    string_ encoded_value = v.to_json();

    EXPECT_EQ("false", encoded_value);
  }
}

TEST(VariantTest, JsonEncodingString) {
  Var v("hello");

  string_ encoded_value = v.to_json();

  EXPECT_EQ("\"hello\"", encoded_value);
}

TEST(VariantTest, JsonEncodingNull) {
  Var v;

  string_ encoded_value = v.to_json();

  EXPECT_EQ("null", encoded_value);
}

TEST(VariantTest, JsonEncodingArray) {
  Var v{Var("hello"), Var(123), Var(true)};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("[\"hello\",123,true]", encoded_value);
}

TEST(VariantTest, JsonEncodingMap) {
  Var v{{"string", Var("hello")},
            {"int", Var(123)},
            {"bool", Var(true)}};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"bool\":true,\"int\":123,\"string\":\"hello\"}", encoded_value);
}

TEST(VariantTest, JsonEncodingNestedArray) {
  Var v{{"string", Var("hello")},
            {"int", Var(123)},
            {"map", {{"first", Var("one")}, {"second", Var("two")}}}};

  string_ encoded_value = v.to_json();

  EXPECT_EQ("{\"int\":123,\"map\":{\"first\":\"one\",\"second\":\"two\"},\"string\":\"hello\"}", encoded_value);
}


{'fraction_non_alphanumeric': 0.21997656707674282, 'fraction_numerical': 0.01757469244288225, 'mean_word_length': 4.104633781763827, 'pattern_counts': {'":': 25, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '223033', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1236, 'n_words': 206}