<commit_before>extern mod index;

use index::Index;

#[test]
fn test_or_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a + b;
	assert_eq!(c.to_vec(), ~[1, 2, 3, 4]);
}

#[test]
fn test_and_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a * b;
	assert_eq!(c.to_vec(), ~[2, 3]);
}

#[test]
fn test_except_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a - b;
	assert_eq!(c.to_vec(), ~[1]);
}

#[test]
fn test_advanced() {
	let a = Index::new( ~[1, 5, 8] );
	let b = Index::new( ~[0, 1, 5] );
	let c = Index::new( ~[0, 1, 5, 8] );
	let d = a + b - c;
	assert_eq!(d.to_vec(), ~[]);
}

#[test]
fn test_index_of_Index() {
	let a = Index::new( ~[1, 5, 10] );
	let b = a.index_of(5);
	assert_eq!(b, ::index::Found(1));
}

#[test]
fn test2_index_of_Index() {
	let a = Index::new( ~[1, 2, 10] );
	let b = a.index_of(0);
	assert_eq!(b, ::index::FoundLarger(0));
}

#[test]
fn test_strs() {
	let a = Index::new( ~[~"apes", ~"banana", ~"monkey"] );
	let b = Index::new( ~[~"banana", ~"monkey", ~"snakes"] );
	let c = a + b;
	assert_eq!(c.to_vec(), 
		~[~"apes", ~"banana", ~"monkey", ~"snakes"]);
}

#[test]
fn test_example_2() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = Index::new( ~[1, 4] );
	let d = a * (b - c);
	assert_eq!(d.to_vec(), ~[2, 3]);
}

#[test]
fn test_new_check_order() {
	assert!(!Index::check_order( &~[1, 3, 2] ));
}

#[test]
fn test_new_check_order_empty() {
	let a: ~[int] = ~[];
	assert!(Index::check_order(&a));
}

#[test]
fn test_new_check_order_sort_retry() {
	let mut a = ~[1, 3, 2];
	let ordered = Index::check_order(&a);	
	assert!(!ordered);	
	if !ordered {
		a.swap(1, 2);
	}

	let ordered = Index::check_order(&a);
	assert!(ordered);
}
<commit_msg>Added unit test for ownership.<commit_after>extern mod index;

use index::Index;

#[test]
fn test_or_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a + b;
	assert_eq!(c.to_vec(), ~[1, 2, 3, 4]);
}

#[test]
fn test_and_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a * b;
	assert_eq!(c.to_vec(), ~[2, 3]);
}

#[test]
fn test_except_operator() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = a - b;
	assert_eq!(c.to_vec(), ~[1]);
}

#[test]
fn test_advanced() {
	let a = Index::new( ~[1, 5, 8] );
	let b = Index::new( ~[0, 1, 5] );
	let c = Index::new( ~[0, 1, 5, 8] );
	let d = a + b - c;
	assert_eq!(d.to_vec(), ~[]);
}

#[test]
fn test_index_of_Index() {
	let a = Index::new( ~[1, 5, 10] );
	let b = a.index_of(5);
	assert_eq!(b, ::index::Found(1));
}

#[test]
fn test2_index_of_Index() {
	let a = Index::new( ~[1, 2, 10] );
	let b = a.index_of(0);
	assert_eq!(b, ::index::FoundLarger(0));
}

#[test]
fn test_strs() {
	let a = Index::new( ~[~"apes", ~"banana", ~"monkey"] );
	let b = Index::new( ~[~"banana", ~"monkey", ~"snakes"] );
	let c = a + b;
	assert_eq!(c.to_vec(), 
		~[~"apes", ~"banana", ~"monkey", ~"snakes"]);
}

#[test]
fn test_example_2() {
	let a = Index::new( ~[1, 2, 3] );
	let b = Index::new( ~[2, 3, 4] );
	let c = Index::new( ~[1, 4] );
	let d = a * (b - c);
	assert_eq!(d.to_vec(), ~[2, 3]);
}

#[test]
fn test_new_check_order() {
	assert!(!Index::check_order( &~[1, 3, 2] ));
}

#[test]
fn test_new_check_order_empty() {
	let a: ~[int] = ~[];
	assert!(Index::check_order(&a));
}

#[test]
fn test_new_check_order_sort_retry() {
	let mut a = ~[1, 3, 2];
	let ordered = Index::check_order(&a);	
	assert!(!ordered);	
	if !ordered {
		a.swap(1, 2);
	}

	let ordered = Index::check_order(&a);
	assert!(ordered);
}

#[test]
fn test_ownership() {
	let a = Index::new( ~[1, 2, 3] );
	let ref b = a;
	assert_eq!(a.to_vec(), ~[1, 2, 3]);
	assert_eq!(b.to_vec(), ~[1, 2, 3]);
}

{'fraction_non_alphanumeric': 0.2660264728782767, 'fraction_numerical': 0.0371139371917986, 'mean_word_length': 3.972903225806452, 'pattern_counts': {'":': 0, '<': 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': '7267335', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1866, 'n_words': 455}