<commit_before>package com.tomgibara.storage;

import junit.framework.TestCase;

public class StoreTest extends TestCase {

	public void testTransformedBy() {
		
		Store<Integer> s = Stores.intsAndNull(1,2,3);
		assertTrue(s.isNullAllowed());
		Store<Integer> t = s.transformedBy(i -> 2 * i);
		assertEquals(s.count(), t.count());
		for (int i = 0; i < s.count(); i++) {
			assertEquals(s.get(i) * 2, t.get(i).intValue());
		}
		assertTrue(s.isMutable());
		assertFalse(t.isMutable());
		try {
			t.transpose(0, 1);
			fail();
		} catch (IllegalStateException e) {
			/* expected */
		}
		s.set(0, null);
		assertNull(t.get(0));
	}
	
}<commit_msg>Some preliminary test cases.<commit_after>package com.tomgibara.storage;

import static java.util.Arrays.asList;
import junit.framework.TestCase;

public class StoreTest extends TestCase {

	public void testTransformedBy() {
		
		Store<Integer> s = Stores.intsAndNull(1,2,3);
		assertTrue(s.isNullAllowed());
		Store<Integer> t = s.transformedBy(i -> 2 * i);
		assertEquals(s.count(), t.count());
		for (int i = 0; i < s.count(); i++) {
			assertEquals(s.get(i) * 2, t.get(i).intValue());
		}
		assertTrue(s.isMutable());
		assertFalse(t.isMutable());
		try {
			t.transpose(0, 1);
			fail();
		} catch (IllegalStateException e) {
			/* expected */
		}
		s.set(0, null);
		assertNull(t.get(0));
	}
	
	public void testNullableResizedCopy() {
		Store<Integer> s = Stores.intsAndNull(1,2,3);
		Store<Integer> t = s.resizedCopy(5);
		assertTrue(t.isMutable());
		assertTrue(t.isNullAllowed());
		assertEquals(asList(1,2,3,null,null), t.asList());
		Store<Integer> u = s.immutableCopy();
		t.set(0, 0);
		t.set(3, 0);
		t.set(4, 0);
		assertEquals(asList(0,2,3,0,0), t.asList());
		assertEquals(u.asList(), s.asList());
		assertEquals(asList(1,2), s.resizedCopy(2).asList());
	}
	
	public void testResizedCopy() {
		Store<Integer> s = Stores.ints(1,2,3);
		Store<Integer> t = s.resizedCopy(5);
		assertTrue(t.isMutable());
		assertFalse(t.isNullAllowed());
		assertEquals(asList(1,2,3,0,0), t.asList());
		Store<Integer> u = s.immutableCopy();
		t.set(0, 4);
		t.set(3, 4);
		t.set(4, 4);
		assertEquals(asList(4,2,3,4,4), t.asList());
		assertEquals(u.asList(), s.asList());
		assertEquals(asList(1,2), s.resizedCopy(2).asList());
	}
	
}
{'fraction_non_alphanumeric': 0.19605263157894737, 'fraction_numerical': 0.028070175438596492, 'mean_word_length': 4.34192037470726, 'pattern_counts': {'":': 0, '<': 15, '<?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': '2974590', 'n_tokens_mistral': 985, 'n_tokens_neox': 886, 'n_words': 154}