<commit_before>package com.tightdb;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.tightdb.test.DataProviderUtil;

public class JNITableSpecTest {

	@Test(dataProvider = "oneColumn")
	public void shouldDefineOneColumnTable(ColumnType columnType) {
		TableSpec spec = new TableSpec();
		spec.addColumn(columnType, "foo");

		TableBase table = new TableBase();
		table.updateFromSpec(spec);
	}

	@Test(dataProvider = "twoColumns")
	public void shouldDefineTwoColumnsTable(ColumnType columnType, ColumnType columnType2) {
		TableSpec spec = new TableSpec();
		spec.addColumn(columnType, "foo");

		TableSpec subspec = spec.addSubtableColumn("bar");
		subspec.addColumn(columnType2, "subbar");

		TableBase table = new TableBase();
		table.updateFromSpec(spec);
	}

	@DataProvider(name = "oneColumn")
	public Iterator<Object[]> oneColumn() {
		return DataProviderUtil.allCombinations(columnTypes());
	}

	@DataProvider(name = "twoColumns")
	public Iterator<Object[]> twoColumns() {
		return DataProviderUtil.allCombinations(columnTypes(), columnTypes());
	}

	private List<?> columnTypes() {
		return Arrays.asList(ColumnType.ColumnTypeBinary, ColumnType.ColumnTypeBool, ColumnType.ColumnTypeDate,
				ColumnType.ColumnTypeInt, ColumnType.ColumnTypeMixed, ColumnType.ColumnTypeString, ColumnType.ColumnTypeTable);
		//return Arrays.asList(ColumnType.values()); // Can't include the ColumnTypeStringEnum - it's not valid user type
	}

}<commit_msg>Added new tests for spec identity and introspection.<commit_after>package com.tightdb;

import static org.testng.AssertJUnit.*;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.tightdb.test.DataProviderUtil;

public class JNITableSpecTest {

	@Test(dataProvider = "oneColumn")
	public void shouldDefineOneColumnTable(ColumnType columnType) {
		TableSpec spec = new TableSpec();
		spec.addColumn(columnType, "foo");
		assertEquals(0, spec.getColumnIndex("foo"));
		assertEquals(-1, spec.getColumnIndex("xx"));
		
		TableSpec spec2 = new TableSpec();
		spec2.addColumn(columnType, "foo");
		checkSpecIdentity(spec, spec2);

		TableBase table = new TableBase();
		table.updateFromSpec(spec);
	}

	@Test(dataProvider = "twoColumns")
	public void shouldDefineTwoColumnsTable(ColumnType columnType, ColumnType columnType2) {
		TableSpec spec = new TableSpec();
		spec.addColumn(columnType, "foo");
		TableSpec subspec = spec.addSubtableColumn("bar");
		subspec.addColumn(columnType2, "subbar");
		assertEquals(0, spec.getColumnIndex("foo"));
		assertEquals(1, spec.getColumnIndex("bar"));
		assertEquals(0, subspec.getColumnIndex("subbar"));
		assertEquals(-1, subspec.getColumnIndex("xx"));

		TableSpec spec2 = new TableSpec();
		spec2.addColumn(columnType, "foo");
		TableSpec subspec2 = spec2.addSubtableColumn("bar");
		subspec2.addColumn(columnType2, "subbar");
		
		checkSpecIdentity(spec, spec2);

		TableBase table = new TableBase();
		table.updateFromSpec(spec);
	}

	@DataProvider(name = "oneColumn")
	public Iterator<Object[]> oneColumn() {
		return DataProviderUtil.allCombinations(columnTypes());
	}

	@DataProvider(name = "twoColumns")
	public Iterator<Object[]> twoColumns() {
		return DataProviderUtil.allCombinations(columnTypes(), columnTypes());
	}

	private void checkSpecIdentity(TableSpec spec, TableSpec spec2) {
		assertEquals(spec, spec2);
		assertEquals(spec.hashCode(), spec2.hashCode());
	}
	
	private List<?> columnTypes() {
		return Arrays.asList(ColumnType.ColumnTypeBinary, ColumnType.ColumnTypeBool, ColumnType.ColumnTypeDate,
				ColumnType.ColumnTypeInt, ColumnType.ColumnTypeMixed, ColumnType.ColumnTypeString, ColumnType.ColumnTypeTable);
		//return Arrays.asList(ColumnType.values()); // Can't include the ColumnTypeStringEnum - it's not valid user type
	}

}
{'fraction_non_alphanumeric': 0.12298792756539235, 'fraction_numerical': 0.005784708249496982, 'mean_word_length': 6.24408014571949, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4222094', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1203, 'n_words': 243}