<commit_before>package be.adaxisoft.flat;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;

public class SerializationTest {

	private String complexJson = "{ "
			+ " \"string\": \"aString\", "
			+ " \"integer\": -1, "
			+ " \"nested\": { "
			+ "		\"x\": 1, "
			+ "		\"y\": 2, "
			+ "		\"z\": 3  }, "
			+ " \"moreNested\": { "
			+ "		\"a\": [1,2,3], "
			+ "		\"b\": [4,5,6], "
			+ "		\"c\": [7,8,9]}, "
			+ " \"arrayFromHell\": ["
			+ "		{ "
			+ "			\"innerArray\": ["
			+ "								{ \"innerInnerArray\": [1,2,3]}"
			+ "							]"
			+ "		}"
			+ "	]}";

	private String[] complexJsonKeys = {
			"arrayFromHell.0.innerArray.0.innerInnerArray.0",
			"arrayFromHell.0.innerArray.0.innerInnerArray.1",
			"arrayFromHell.0.innerArray.0.innerInnerArray.2",
			"nested.z",
			"nested.y",
			"nested.x",
			"integer",
			"string",
			"moreNested.b.0",
			"moreNested.b.1",
			"moreNested.b.2",
			"moreNested.c.0",
			"moreNested.c.1",
			"moreNested.c.2",
			"moreNested.a.0",
			"moreNested.a.1",
			"moreNested.a.2",
	};

	@Test
	public void flattenStringNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		Flat.flatten(jsonString);
	}

	@Test
	public void flattenStringWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		Flat.flatten(jsonString, "-");
	}

	@Test
	public void flattenObjectNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.flatten(jsonObject);
	}

	@Test
	public void flattenObjectWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.flatten(jsonObject, "-");
	}

	@Test
	public void flattenStringNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		Flat.flattenToJSONObject(jsonString);
	}

	@Test
	public void flattenStringWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		Flat.flattenToJSONObject(jsonString, "-");
	}

	@Test
	public void flattenObjectNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.flattenToJSONObject(jsonObject);
	}

	@Test
	public void flattenObjectWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.flattenToJSONObject(jsonObject, "-");
	}

	@Test
	public void unflattenStringNoDelimiter() {
		String jsonString = "{ \"a.b\": 1 }}";
		Flat.unflatten(jsonString);
	}

	@Test
	public void unflattenStringWithDelimiter() {
		String jsonString = "{ \"a-b\": 1 }}";
		Flat.unflatten(jsonString, "-");
	}

	@Test
	public void unflattenObjectNoDelimiter() {
		String jsonString = "{ \"a.b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.unflatten(jsonObject);
	}

	@Test
	public void unflattenObjectWithDelimiter() {
		String jsonString = "{ \"a-b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.unflatten(jsonObject, "-");
	}

	@Test
	public void unflattenStringNoDelimiterToObject() {
		String jsonString = "{ \"a.b\": 1 }}";
		Flat.unflattenToJSONObject(jsonString);
	}

	@Test
	public void unflattenStringWithDelimiterToObject() {
		String jsonString = "{ \"a-b\": 1 }}";
		Flat.unflattenToJSONObject(jsonString, "-");
	}

	@Test
	public void unflattenObjectNoDelimiterToObject() {
		String jsonString = "{ \"a.b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.unflattenToJSONObject(jsonObject);
	}

	@Test
	public void unflattenObjectWithDelimiterToObject() {
		String jsonString = "{ \"a-b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		Flat.unflattenToJSONObject(jsonObject, "-");
	}
<commit_msg>Add valid assertion to basic tests<commit_after>package be.adaxisoft.flat;

import static org.junit.Assert.*;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;

public class SerializationTest {

	private String complexJson = "{ "
			+ " \"string\": \"aString\", "
			+ " \"integer\": -1, "
			+ " \"nested\": { "
			+ "		\"x\": 1, "
			+ "		\"y\": 2, "
			+ "		\"z\": 3  }, "
			+ " \"moreNested\": { "
			+ "		\"a\": [1,2,3], "
			+ "		\"b\": [4,5,6], "
			+ "		\"c\": [7,8,9]}, "
			+ " \"arrayFromHell\": ["
			+ "		{ "
			+ "			\"innerArray\": ["
			+ "								{ \"innerInnerArray\": [1,2,3]}"
			+ "							]"
			+ "		}"
			+ "	]}";

	private String[] complexJsonKeys = {
			"arrayFromHell.0.innerArray.0.innerInnerArray.0",
			"arrayFromHell.0.innerArray.0.innerInnerArray.1",
			"arrayFromHell.0.innerArray.0.innerInnerArray.2",
			"nested.z",
			"nested.y",
			"nested.x",
			"integer",
			"string",
			"moreNested.b.0",
			"moreNested.b.1",
			"moreNested.b.2",
			"moreNested.c.0",
			"moreNested.c.1",
			"moreNested.c.2",
			"moreNested.a.0",
			"moreNested.a.1",
			"moreNested.a.2",
	};

	@Test
	public void flattenStringNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				new JSONObject(Flat.flatten(jsonString)).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenStringWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				new JSONObject(Flat.flatten(jsonString, "-")).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenObjectNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		String flatJsonString = "{ \"a.b\": 1 }}";
		Flat.flatten(jsonObject);
		assertTrue("The flattened is not similar to the expected value. ", 
				new JSONObject(Flat.flatten(jsonObject)).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenObjectWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				new JSONObject(Flat.flatten(jsonObject, "-")).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenStringNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				Flat.flattenToJSONObject(jsonString).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenStringWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				Flat.flattenToJSONObject(jsonString, "-").similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenObjectNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		String flatJsonString = "{ \"a.b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				Flat.flattenToJSONObject(jsonObject).similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void flattenObjectWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		JSONObject jsonObject = new JSONObject(jsonString);
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The flattened is not similar to the expected value. ", 
				Flat.flattenToJSONObject(jsonObject, "-").similar(new JSONObject(flatJsonString)));
	}

	@Test
	public void unflattenStringNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		assertTrue("The unflattened is not similar to the expected value. ", 
				new JSONObject(Flat.unflatten(flatJsonString)).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenStringWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The unflattened is not similar to the expected value. ", 
				new JSONObject(Flat.unflatten(flatJsonString, "-")).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenObjectNoDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		JSONObject flatJsonObject = new JSONObject(flatJsonString);
		assertTrue("The unflattened is not similar to the expected value. ", 
				new JSONObject(Flat.unflatten(flatJsonObject)).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenObjectWithDelimiter() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		JSONObject flatJsonObject = new JSONObject(flatJsonString);
		assertTrue("The unflattened is not similar to the expected value. ", 
				new JSONObject(Flat.unflatten(flatJsonObject, "-")).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenStringNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		assertTrue("The unflattened is not similar to the expected value. ", 
				Flat.unflattenToJSONObject(flatJsonString).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenStringWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		assertTrue("The unflattened is not similar to the expected value. ", 
				Flat.unflattenToJSONObject(flatJsonString, "-").similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenObjectNoDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a.b\": 1 }}";
		JSONObject flatJsonObject = new JSONObject(flatJsonString);
		assertTrue("The unflattened is not similar to the expected value. ", 
				Flat.unflattenToJSONObject(flatJsonObject).similar(new JSONObject(jsonString)));
	}

	@Test
	public void unflattenObjectWithDelimiterToObject() {
		String jsonString = "{ \"a\": { \"b\": 1 }}";
		String flatJsonString = "{ \"a-b\": 1 }}";
		JSONObject flatJsonObject = new JSONObject(flatJsonString);
		assertTrue("The unflattened is not similar to the expected value. ", 
				Flat.unflattenToJSONObject(flatJsonObject, "-").similar(new JSONObject(jsonString)));
	}

{'fraction_non_alphanumeric': 0.18297465327594453, 'fraction_numerical': 0.011095169775227164, 'mean_word_length': 3.7226738934056005, 'pattern_counts': {'":': 98, '<': 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': '2364920', 'n_tokens_mistral': 4018, 'n_tokens_neox': 3630, 'n_words': 743}