java_test.cpp

Go to the documentation of this file.
00001 
00013 #include "demangle_java_symbol.h"
00014 
00015 #include "op_regex.h"
00016 
00017 #include <iostream>
00018 #include <fstream>
00019 
00020 #include <cstdlib>
00021 
00022 using namespace std;
00023 
00024 namespace {
00025 
00026 void check_result(string const & input, string const & output,
00027              string const & result)
00028 {
00029     if (result != output) {
00030         cerr << "for:\n\"" << input << "\"\n"
00031              << "expect:\n\"" << output << "\"\n"
00032              << "found:\n\"" << result << "\"\n";
00033         exit(EXIT_FAILURE);
00034     }
00035 }
00036 
00037 struct input_output {
00038     char const * mangled;
00039     char const * expect;
00040 };
00041 
00042 input_output mangle_tests[] = {
00043     { "Ltest$test_1;f2(I)V", "void test$test_1.f2(int)" },
00044     { "Ltest;f4()V", "void test.f4()" },
00045     { "Ltest;f2(II)V", "void test.f2(int, int)" },
00046     { "Ltest$HelloThread;run()V~1", "void test$HelloThread.run()~1" },
00047     { "Lsun/security/provider/SHA;implCompress([BI)V", "void sun.security.provider.SHA.implCompress(byte[], int)" },
00048     { "Ljava/lang/String;equals(Ljava/lang/Object;)Z", "boolean java.lang.String.equals(java.lang.Object)" },
00049     { "Lorg/eclipse/swt/graphics/ImageData;blit(I[BIIIIIIIIIII[BIII[BIIIIIIIIIIZZ)V", "void org.eclipse.swt.graphics.ImageData.blit(int, byte[], int, int, int, int, int, int, int, int, int, int, int, byte[], int, int, int, byte[], int, int, int, int, int, int, int, int, int, int, boolean, boolean)" },
00050     { 0, 0 }
00051 };
00052 
00053 } // anonymous namespace
00054 
00055 int main(void)
00056 {
00057     input_output const * cur;
00058     for (cur = mangle_tests; cur->mangled; ++cur) {
00059         string result = demangle_java_symbol(cur->mangled);
00060         check_result(cur->mangled, cur->expect, result);
00061     }
00062 
00063     return 0;
00064 }
00065 

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1