Skip to content

Instantly share code, notes, and snippets.

@bkerley
Created August 25, 2014 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkerley/7c879857aa1078fd3caa to your computer and use it in GitHub Desktop.
Save bkerley/7c879857aa1078fd3caa to your computer and use it in GitHub Desktop.
#!/bin/sh
gcc -o idunno idunno.c
#include <stdio.h>
int main() {
long long first, second;
puts("enter two integers");
scanf("%lld %lld", &first, &second);
printf("%d\n", first + second);
return 0;
}
def idunno(a, b)
out = nil
IO.popen './idunno', 'r+' do |io|
io.puts a
io.puts b
read = io.gets
read = io.gets
out = read.to_i
end
end
describe 'idunno' do
describe 'addition' do
it 'adds 2 and 2 to make 4' do
expect(idunno(2, 2)).to eq 4
end
it 'adds 2 and 3 to make 5' do
expect(idunno(2, 3)).to eq 5
end
100.times do
n1 = rand 2**31
n2 = rand 2**31
sum = n1 + n2
it "adds #{n1} and #{n2} to make #{sum}" do
expect(idunno(n1, n2)).to eq sum
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment