Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
w-culhane committed May 8, 2018
1 parent 75d8b44 commit c24c50a
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "heliometer"
version = "0.4.10"
version = "0.4.13"
description = "A basic brainfuck interpreter"
authors = [ "LEARAX57H <willculhane3@gmail.com>",
"vpzomtrrfrt <eric@gloriouswill.com>" ]
Expand Down
6 changes: 6 additions & 0 deletions examples/bsort.bf
@@ -1,3 +1,7 @@
[bsort.b -- bubble sort
(c) 2016 Daniel B. Cristofani
http://brainfuck.org/]
>>,[>>,]<<[
[<<]>>>>[
<<[>+<<+>-]
Expand All @@ -6,3 +10,5 @@
>>[[<+>-]>>]<
]<<[>>+<<-]<<
]>>>>[.>>]
[This program sorts the bytes of its input by bubble sort.]
11 changes: 11 additions & 0 deletions examples/isort.bf
@@ -0,0 +1,11 @@
[isort.b -- insertion sort
(c) 2016 Daniel B. Cristofani
http://brainfuck.org/]
>>+>,[
<[
[>>+<<-]>[<<+<[->>+[<]]>>>[>]<<-]<<<
]>>[<<+>>-]<[>+<-]>[>>]<,
]<<<[<+<]>[>.>]
[This program sorts bytes of input using insertion sort.]
145 changes: 145 additions & 0 deletions examples/mandelbrot.bf
@@ -0,0 +1,145 @@
A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<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<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<
<<<]>>>>>>>>-<<<<<[-]+<<<]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>->[>>>
>>>[->>+<<]>>>]<<<<<<<<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<
<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>
+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+<
<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<
<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>
-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>
>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
<<<<<]]>>>]
2 changes: 2 additions & 0 deletions examples/other.bf
@@ -0,0 +1,2 @@
[]++++++++++[>>+>+>++++++[<<+<+++>>>-]<<<<-]
"A*$";?@![#>>+<<]>[>>]<<<<[>++<[-]]>.>.
9 changes: 9 additions & 0 deletions examples/qsort.bf
@@ -0,0 +1,9 @@
[qsort.b -- quicksort
(c) 2016 Daniel B. Cristofani
http://brainfuck.org/]
>>+>>>>>,[>+>>,]>+[--[+<<<-]<[<+>-]<[<[->[<<<+>>>>+<-]<<[>>+>[->]<<[<]
<-]>]>>>+<[[-]<[>+<-]<]>[[>>>]+<<<-<[<<[<<<]>>+>[>>>]<-]<<[<<<]>[>>[>>
>]<+<<[<<<]>-]]+<<<]+[->>>]>>]>>[.>>>]
[This program sorts input bytes via quicksort.]
24 changes: 24 additions & 0 deletions examples/rot13.bf
@@ -0,0 +1,24 @@
,
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>++++++++++++++<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>>+++++[<----->-]<<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>++++++++++++++<-
[>+<-[>+<-[>+<-[>+<-[>+<-
[>++++++++++++++<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>>+++++[<----->-]<<-
[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-
[>++++++++++++++<-
[>+<-]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]>.[-]<,]
of course any function char f(char) can be made easily on the same principle
[Daniel B Cristofani (cristofdathevanetdotcom)
http://www.hevanet.com/cristofd/brainfuck/]
1 change: 1 addition & 0 deletions examples/unmatched_left.bf
@@ -0,0 +1 @@
+++++[>+++++++>++<<-]>.>.[
80 changes: 76 additions & 4 deletions tests/tests.rs
Expand Up @@ -33,8 +33,8 @@ mod tests {
let mut file = std::fs::File::open("examples/far_right.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![0; 1]);
let mut fake_output = std::io::Cursor::new(vec![0; 1]);
let mut fake_input = std::io::Cursor::new(vec![0]);
let mut fake_output = std::io::Cursor::new(vec![0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref()[0], &b'#');
}
Expand All @@ -44,8 +44,8 @@ mod tests {
let mut file = std::fs::File::open("examples/256.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![0; 1]);
let mut fake_output = std::io::Cursor::new(vec![0; 1]);
let mut fake_input = std::io::Cursor::new(vec![0]);
let mut fake_output = std::io::Cursor::new(vec![0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref()[0], &0);
}
Expand All @@ -61,4 +61,76 @@ mod tests {
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref(), &expected_output.get_ref());
}

#[test]
fn insertion_sort() {
let mut file = std::fs::File::open("examples/isort.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![50, 20, 19, 255, 19, 4, 103, 57, 0, 53]);
let mut fake_output = std::io::Cursor::new(vec![0; 10]);
let expected_output = std::io::Cursor::new(vec![4, 19, 19, 20, 50, 57, 103, 255, 0, 0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref(), &expected_output.get_ref());
}

#[test]
fn quick_sort() {
let mut file = std::fs::File::open("examples/qsort.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![50, 20, 19, 255, 19, 4, 103, 57, 0, 53]);
let mut fake_output = std::io::Cursor::new(vec![0; 10]);
let expected_output = std::io::Cursor::new(vec![4, 19, 19, 20, 50, 57, 103, 255, 0, 0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref(), &expected_output.get_ref());
}

#[test]
fn rot13() {
let mut file = std::fs::File::open("examples/rot13.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![37, 85, 200, 0]);
let mut fake_output = std::io::Cursor::new(vec![0; 4]);
let expected_output = std::io::Cursor::new(vec![37, 72, 200, 0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref(), &expected_output.get_ref());
}

#[should_panic]
#[test]
fn unmatched_right_bracket() {
let mut file = std::fs::File::open("examples/unmatched_right.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![0]);
let mut fake_output = std::io::Cursor::new(vec![0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
}

/*
* #[should_panic]
* #[test]
* fn unmatched_left_bracket() {
* let mut file = std::fs::File::open("examples/unmatched_left.bf").unwrap();
* let mut input = String::new();
* file.read_to_string(&mut input).unwrap();
* let mut fake_input = std::io::Cursor::new(vec![0]);
* let mut fake_output = std::io::Cursor::new(vec![0]);
* heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
* }
*/

#[test]
fn other_program_check() {
let mut file = std::fs::File::open("examples/other.bf").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut fake_input = std::io::Cursor::new(vec![0]);
let mut fake_output = std::io::Cursor::new(vec![0]);
heliometer::execute(&input, &mut fake_input, &mut fake_output).unwrap();
assert_eq!(&fake_output.get_ref()[0], &b'H');
}

}

0 comments on commit c24c50a

Please sign in to comment.