diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 21:41:27 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:50 +0200 |
commit | a611d82983c7a6d08039b60ac93fd89fe82e875d (patch) | |
tree | 3f8e4f46f845513f32269774e6607f056218952c /tests | |
parent | d7c0304077629708b140b3d7b4f567216a684487 (diff) |
Use do_run_from_file() for test_bswap64
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_bswap64.in | 56 | ||||
-rw-r--r-- | tests/core/test_bswap64.out | 7 | ||||
-rw-r--r-- | tests/test_core.py | 66 |
3 files changed, 66 insertions, 63 deletions
diff --git a/tests/core/test_bswap64.in b/tests/core/test_bswap64.in new file mode 100644 index 00000000..addf6086 --- /dev/null +++ b/tests/core/test_bswap64.in @@ -0,0 +1,56 @@ + + #include <stdio.h> + #include <stdlib.h> + + #include <iostream> + #include <string> + #include <sstream> + + typedef unsigned long long quint64; + + using namespace std; + + inline quint64 qbswap(quint64 source) + { + return 0 + | ((source & quint64(0x00000000000000ffLL)) << 56) + | ((source & quint64(0x000000000000ff00LL)) << 40) + | ((source & quint64(0x0000000000ff0000LL)) << 24) + | ((source & quint64(0x00000000ff000000LL)) << 8) + | ((source & quint64(0x000000ff00000000LL)) >> 8) + | ((source & quint64(0x0000ff0000000000LL)) >> 24) + | ((source & quint64(0x00ff000000000000LL)) >> 40) + | ((source & quint64(0xff00000000000000LL)) >> 56); + } + + int main() + { + quint64 v = strtoull("4433ffeeddccbb00", NULL, 16); + printf("%lld\n", v); + + const string string64bitInt = "4433ffeeddccbb00"; + stringstream s(string64bitInt); + quint64 int64bitInt = 0; + printf("1\n"); + s >> hex >> int64bitInt; + printf("2\n"); + + stringstream out; + out << hex << qbswap(int64bitInt); + + cout << out.str() << endl; + cout << hex << int64bitInt << endl; + cout << string64bitInt << endl; + + if (out.str() != "bbccddeeff3344") + { + cout << "Failed!" << endl; + } + else + { + cout << "Succeeded!" << endl; + } + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_bswap64.out b/tests/core/test_bswap64.out new file mode 100644 index 00000000..af129b5f --- /dev/null +++ b/tests/core/test_bswap64.out @@ -0,0 +1,7 @@ +4914553019779824384 +1 +2 +bbccddeeff3344 +4433ffeeddccbb00 +4433ffeeddccbb00 +Succeeded! diff --git a/tests/test_core.py b/tests/test_core.py index a67f0afe..0ddbede2 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -485,70 +485,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_bswap64(self): if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2') - src = r''' - #include <stdio.h> - #include <stdlib.h> - - #include <iostream> - #include <string> - #include <sstream> - - typedef unsigned long long quint64; - - using namespace std; - - inline quint64 qbswap(quint64 source) - { - return 0 - | ((source & quint64(0x00000000000000ffLL)) << 56) - | ((source & quint64(0x000000000000ff00LL)) << 40) - | ((source & quint64(0x0000000000ff0000LL)) << 24) - | ((source & quint64(0x00000000ff000000LL)) << 8) - | ((source & quint64(0x000000ff00000000LL)) >> 8) - | ((source & quint64(0x0000ff0000000000LL)) >> 24) - | ((source & quint64(0x00ff000000000000LL)) >> 40) - | ((source & quint64(0xff00000000000000LL)) >> 56); - } - - int main() - { - quint64 v = strtoull("4433ffeeddccbb00", NULL, 16); - printf("%lld\n", v); - - const string string64bitInt = "4433ffeeddccbb00"; - stringstream s(string64bitInt); - quint64 int64bitInt = 0; - printf("1\n"); - s >> hex >> int64bitInt; - printf("2\n"); - - stringstream out; - out << hex << qbswap(int64bitInt); - - cout << out.str() << endl; - cout << hex << int64bitInt << endl; - cout << string64bitInt << endl; - - if (out.str() != "bbccddeeff3344") - { - cout << "Failed!" << endl; - } - else - { - cout << "Succeeded!" << endl; - } + test_path = path_from_root('tests', 'core', 'test_bswap64') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - self.do_run(src, '''4914553019779824384 -1 -2 -bbccddeeff3344 -4433ffeeddccbb00 -4433ffeeddccbb00 -Succeeded! -''') + self.do_run_from_file(src, output) def test_sha1(self): if self.emcc_args == None: return self.skip('needs ta2') |