Add history view test

This commit is contained in:
bootstraponline
2012-11-14 21:03:24 -07:00
parent 9cf469b035
commit 3d21ed362e
2 changed files with 31 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
# ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/frontend/views/history', __FILE__
context "Precious::Views::History" do
setup do
@history = Precious::Views::History.new
end
test "string_to_code" do
# Result must match the following Java code.
=begin
public static void main(String[] args) throws Exception {
final String s = "code@example.com";
final byte[] b = MessageDigest.getInstance("SHA1").digest(s.toString().getBytes("UTF-8"));
final int c = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
| ((b[2] & 0xFF) << 8) | (b[3] & 0xFF);
// 143327882
System.out.println(c);
}
=end
actual = @history.string_to_code 'code@example.com'
assert_equal 143327882, actual
end
end