<commit_before>#include "../LFC/LFC.h"
#include "testdictionary.h"

TestDictionary::TestDictionary()
{
}

TestDictionary::~TestDictionary()
{
}

int TestDictionary::Perform()
{
	Dictionary<Text *, int> d1(Text::COMPARER);
	d1.SetKey(new Text("Luis"), 10);
	d1.SetKey(new Text("Pedro"), 4);
	d1.SetKey(new Text("Alvaro"), 20);
	d1.SetKey(new Text("Luis"), 12);
	d1.SetKey(new Text("Zacarias"), 23);
	d1.SetKey(new Text("Armando"), 15);
	
	int iAux = 0;
	Collection<Text *> keys = d1.Keys();
	Collection<int> values = d1.Values();
	for (int i=0; i<keys.Count(); i++) {
		if (!d1.GetKey(keys[i], iAux)) {
			StdOut::PrintLine("Dictionary<K, V>::GetKey didn't work!!!");
			return -1;
		}
		if (iAux != values[i]) {
			StdOut::PrintLine("Dictionary<K, V>::Values didn't work!!!");
			return -1;
		}
		StdOut::PrintLine(*keys[i] + " " + iAux);
	}
	
	Text t = "Luis";
	d1.ClearKey(&t);
	if (d1.ExistsKey(&t)) {
		StdOut::PrintLine("ClearKey and ExistsKey doesn't work!!!");
		return -1;
	}
	
	NObjectDictionary d2;
	d2.SetKey(new Text("Octubre"), new Text("Rojo"));
	d2.SetKey(new Text("Manolo"), new Text("Machado"));
	d2.SetKey(new Text("Carmen"), new Text("Chacon"));
	d2.SetKey(new Text("Felipe"), new Text("González"));
	NObject *oaux = NULL;
	Collection<NObject *> d2keys = d2.Keys();
	for (int i=0; i<d2keys.Count(); i++) {
		if (d2.GetKey(d2keys[i], oaux)) continue;
		StdOut::PrintLine("NObjectDictionary error!!!");
		return -1;
	}
	StdOut::PrintLine(d2.ToText());
	d2.DeleteAndClear();
	
	return 0;
}

<commit_msg>Added NObjectDictionary test<commit_after>#include "../LFC/LFC.h"
#include "testdictionary.h"

TestDictionary::TestDictionary()
{
}

TestDictionary::~TestDictionary()
{
}

int TestDictionary::Perform()
{
	Dictionary<Text *, int> d1(Text::COMPARER);
	d1.SetKey(new Text("Luis"), 10);
	d1.SetKey(new Text("Pedro"), 4);
	d1.SetKey(new Text("Alvaro"), 20);
	d1.SetKey(new Text("Luis"), 12);
	d1.SetKey(new Text("Zacarias"), 23);
	d1.SetKey(new Text("Armando"), 15);
	
	int iAux = 0;
	Collection<Text *> keys = d1.Keys();
	Collection<int> values = d1.Values();
	for (int i=0; i<keys.Count(); i++) {
		if (!d1.GetKey(keys[i], iAux)) {
			StdOut::PrintLine("Dictionary<K, V>::GetKey didn't work!!!");
			return -1;
		}
		if (iAux != values[i]) {
			StdOut::PrintLine("Dictionary<K, V>::Values didn't work!!!");
			return -1;
		}
		StdOut::PrintLine(*keys[i] + " " + iAux);
	}
	
	Text t = "Luis";
	d1.ClearKey(&t);
	if (d1.ExistsKey(&t)) {
		StdOut::PrintLine("ClearKey and ExistsKey doesn't work!!!");
		return -1;
	}
	
	NObjectDictionary d2;
	d2.SetKey(new Text("Octubre"), new Text("Rojo"));
	d2.SetKey(new Text("Manolo"), new Text("Machado"));
	d2.SetKey(new Text("Carmen"), new Text("Chacon"));
	d2.SetKey(new Text("Felipe"), new Text("González"));
	NObject *oaux = NULL;
	Collection<NObject *> d2keys = d2.Keys();
	for (int i=0; i<d2keys.Count(); i++) {
		if (d2.GetKey(d2keys[i], oaux)) continue;
		StdOut::PrintLine("NObjectDictionary error!!!");
		return -1;
	}
	StdOut::PrintLine(d2.ToText());
	d2.DeleteAndClear();
	
	try { 
		d2.SetKey(NULL, new Text("aaa")); 
		StdOut::PrintLine("Exception should have been raised.");
		return -1;
	} catch (Exception *e) {
		delete e;
	}
	
	try { 
		d2.SetKey(new Text("aaa"), NULL); 
		StdOut::PrintLine("Exception should have been raised.");
		return -1;
	} catch (Exception *e) {
		delete e;
	}
	
	return 0;
}


{'fraction_non_alphanumeric': 0.21464571597983992, 'fraction_numerical': 0.026682478505781204, 'mean_word_length': 4.827288428324698, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, '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': '4207012', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1363, 'n_words': 268}