int main() { std::cout << "this is bar_test, hello\n"; test_negative(); test_positive(); test_zero(); }
void test() { srand(time(0)); for (int u = 0; u < MAX_TESTS; ++u) test_positive(); for (int u = 0; u < MAX_TESTS; ++u) test_negative(); }
// Функция загрузки файла проницаемостей void load_permeability(double* K) { for (int i = 0; i < def.locNx; i++) for (int j = 0; j < def.locNy; j++) for (int k = 0; k < def.locNz; k++) { K[i + j * def.locNx + k * def.locNx * def.locNy] = def.K[0]; test_positive(K[i+j*def.locNx+k*def.locNx*def.locNy], __FILE__, __LINE__); } }
TEST(XmlVersionDeclParser, PositiveTests) { // <?xml version='1.0' ?> should match test_positive("<?xml version='1.0' ?>"); // <?xml version='1.0' ?> with more spaces should match test_positive("<?xml version='1.0' ?>"); // <?xml version='1.0' ?> with tab should match test_positive("<?xml \t version='1.0' \t ?>"); // <?xml version='1.0' encoding='UTF-8' ?> should match test_positive("<?xml version='1.0' encoding='UTF-8' ?>"); // <?xml version="1.0" encoding="UTF-8" ?> should match test_positive("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); // <?xml version="1.0" encoding='UTF-8' ?> should match test_positive("<?xml version=\"1.0\" encoding='UTF-8' ?>"); // <?xml version='1.0' encoding="UTF-8" ?> should match test_positive("<?xml version='1.0' encoding=\"UTF-8\" ?>"); }
TEST(XmlRpcArrayElementParser, PositiveTests) { // <object /> should be a match auto && val1 = test_positive("<object />"); EXPECT_EQ(0, val1.size()); // <array></array> should be a match auto && val2 = test_positive("<object></object>"); EXPECT_EQ(0, val2.size()); // object of 1 property { auto && val = test_positive("<object><p1>abc</p1></object>"); EXPECT_EQ(1, val.size()); // p1 auto found_p1 = count_properties(val, "p1") == 1; EXPECT_TRUE(found_p1); auto &p1 = get_property(val, "p1"); EXPECT_EQ("abc", boost::get<std::string>(p1)); } // object of 1 property, with space { auto && val = test_positive("<object> <p1>abc</p1> </object>"); EXPECT_EQ(1, val.size()); // p1 auto found_p1 = count_properties(val, "p1") == 1; EXPECT_TRUE(found_p1); auto &p1 = get_property(val, "p1"); EXPECT_EQ("abc", boost::get<std::string>(p1)); } // object of 1 bool property, with space { auto && val = test_positive("<object> <p1><true /></p1> </object>"); EXPECT_EQ(1, val.size()); // p1 auto found_p1 = count_properties(val, "p1") == 1; EXPECT_TRUE(found_p1); auto &p1 = get_property(val, "p1"); EXPECT_EQ(true, boost::get<bool>(p1)); } // object of 1 int property, with space { auto && val = test_positive("<object><p1><int>100</int></p1></object>"); EXPECT_EQ(1, val.size()); // p1 auto found_p1 = count_properties(val, "p1") == 1; EXPECT_TRUE(found_p1); auto &p1 = get_property(val, "p1"); EXPECT_EQ(100, boost::get<int>(p1)); } // object of mixed property types { auto && val = test_positive("\ <object>\ <p1><int>100</int></p1>\ <p2>hello, world</p2>\ <p3><true /></p3>\ </object>"); EXPECT_EQ(3, val.size()); // p1 auto found_p1 = count_properties(val, "p1") == 1; EXPECT_TRUE(found_p1); auto &p1 = get_property(val, "p1"); EXPECT_EQ(100, boost::get<int>(p1)); // p2 auto found_p2 = count_properties(val, "p2") == 1; EXPECT_TRUE(found_p2); auto &p2 = get_property(val, "p2"); EXPECT_EQ("hello, world", boost::get<std::string>(p2)); // p3 auto found_p3 = count_properties(val, "p3") == 1; EXPECT_TRUE(found_p3); auto &p3 = get_property(val, "p3"); EXPECT_EQ(true, boost::get<bool>(p3)); } }
// Вычисление расчетной области (нагрузки) процессора // Если поровну не распределяется, то первые (def.NX)%size получают +1 в нагрузку. // Каждый процессор содержит дополнительную точку в массиве для // обмена данными, если имеет соседа // (если 2 соседа с обеих сторон,то +2 точки). // Глобальные границы хранятся как обычные точки (отсюда и условие на (def.rank)==0) void global_to_local_vars() { def.locNx = def.Nx / def.sizex; if (def.rankx < def.Nx % def.sizex) { (def.locNx) ++; } // Крайние процессоры получают по 1 точке для граничных данных, // остальные - по 2 на обе границы // Если процессор один, то границ у него нет и дополнительные точки не нужны if (def.sizex > 1) { if ((def.rankx == 0) || (def.rankx == def.sizex - 1)) { (def.locNx) ++; } else { (def.locNx) += 2; } } def.locNy = def.Ny / def.sizey; if ((def.ranky < def.Ny % def.sizey)) { (def.locNy) ++; } if (def.sizey > 1) { if ((def.ranky == 0) || (def.ranky == def.sizey - 1)) { (def.locNy) ++; } else { (def.locNy) += 2; } } def.locNz = def.Nz / def.sizez; if (def.rankz < def.Nz % def.sizez) { (def.locNz) ++; } if (def.sizez > 1) { if ((def.rankz == 0) || (def.rankz == def.sizez - 1)) { (def.locNz) ++; } else { (def.locNz) += 2; } } if(def.rank >= def.sizex * def.sizey * def.sizez) { def.locNx = def.locNy = def.locNz = 0; } test_positive(def.locNx, __FILE__, __LINE__); test_positive(def.locNy, __FILE__, __LINE__); test_positive(def.locNz, __FILE__, __LINE__); }
void data_initialization(long int* t) { *t = 0; for (int i = 0; i < def.locNx; i++) for (int j = 0; j < def.locNy; j++) for (int k = 0; k < def.locNz; k++) { int local = i + j * (def.locNx) + k * (def.locNx) * (def.locNy); HostArraysPtr.m[local]=def.porosity[0]; S_local_initialization(local); /*if ((j == 0) && ((def.source) > 0)) { HostArraysPtr.S_w[local] = def.S_w_gr; HostArraysPtr.S_n[local] = def.S_n_gr; } else { HostArraysPtr.S_w[local] = def.S_w_init; HostArraysPtr.S_n[local] = def.S_n_init; }*/ /*double ro_g_dy = ((def.ro0_g * (1. - HostArraysPtr.S_w[local] - HostArraysPtr.S_n[local]) + def.ro0_w * HostArraysPtr.S_w[local] + def.ro0_n * HostArraysPtr.S_n[local]) * (HostArraysPtr.m[local]) + (1. - HostArraysPtr.m[local]) * 2000.) * (def.g_const) * (def.hy);*/ // Если отдельно задаем значения на границах через градиент //if (j == 0) { HostArraysPtr.P_w[local] = def.P_atm; HostArraysPtr.P_n[local] = def.P_atm; HostArraysPtr.P_g[local] = def.P_atm; } /*else { HostArraysPtr.P_w[local] = HostArraysPtr.P_w[local - (def.locNx)] + ro_g_dy; HostArraysPtr.P_n[local] = HostArraysPtr.P_n[local - (def.locNx)] + ro_g_dy; HostArraysPtr.P_g[local] = HostArraysPtr.P_g[local - (def.locNx)] + ro_g_dy; }*/ HostArraysPtr.ro_w[local] = def.ro0_w * (1. + (def.beta_w) * (HostArraysPtr.P_w[local] - def.P_atm)); HostArraysPtr.ro_n[local] = def.ro0_n * (1. + (def.beta_n) * (HostArraysPtr.P_n[local] - def.P_atm)); HostArraysPtr.ro_g[local] = def.ro0_g * HostArraysPtr.P_g[local] / def.P_atm; #ifdef ENERGY // !!!! Нужно задать начальные распределения температуры, энтальпии, энергии! HostArraysPtr.T[local] = 285; test_positive(HostArraysPtr.T[local], __FILE__, __LINE__); #endif test_S(HostArraysPtr.S_n[local], __FILE__, __LINE__); test_S(HostArraysPtr.S_w[local], __FILE__, __LINE__); test_positive(HostArraysPtr.P_w[local], __FILE__, __LINE__); test_positive(HostArraysPtr.P_n[local], __FILE__, __LINE__); test_positive(HostArraysPtr.P_g[local], __FILE__, __LINE__); test_positive(HostArraysPtr.ro_w[local], __FILE__, __LINE__); test_positive(HostArraysPtr.ro_n[local], __FILE__, __LINE__); test_positive(HostArraysPtr.ro_g[local], __FILE__, __LINE__); } }
int main(int argc, const char *argv[]) { /* * invert output, by */ int flag_invert = FALSE; /* * don't print anything.. useful for * performance monitors, gprof. */ int flag_quiet = FALSE; /* * only print postive results * with invert, only print negative results */ int flag_true = FALSE; detect_mode_t mode = MODE_SQLI; int flag_slow = 1; int count = 0; int max = -1; int i, j; int offset = 1; while (offset < argc) { if (strcmp(argv[offset], "-i") == 0) { offset += 1; flag_invert = TRUE; } else if (strcmp(argv[offset], "-q") == 0) { offset += 1; flag_quiet = TRUE; } else if (strcmp(argv[offset], "-t") == 0) { offset += 1; flag_true = TRUE; } else if (strcmp(argv[offset], "-s") == 0) { offset += 1; flag_slow = 100; } else if (strcmp(argv[offset], "-m") == 0) { offset += 1; max = atoi(argv[offset]); offset += 1; } else if (strcmp(argv[offset], "-x") == 0) { mode = MODE_XSS; offset += 1; } else { break; } } if (offset == argc) { test_positive(stdin, "stdin", mode, flag_invert, flag_true, flag_quiet); } else { for (j = 0; j < flag_slow; ++j) { for (i = offset; i < argc; ++i) { FILE* fd = fopen(argv[i], "r"); if (fd) { test_positive(fd, argv[i], mode, flag_invert, flag_true, flag_quiet); fclose(fd); } } } } if (!flag_quiet) { fprintf(stdout, "%s", "\n"); fprintf(stdout, "SQLI : %d\n", g_test_ok); fprintf(stdout, "SAFE : %d\n", g_test_fail); fprintf(stdout, "TOTAL : %d\n", g_test_ok + g_test_fail); } if (max == -1) { return 0; } count = g_test_ok; if (flag_invert) { count = g_test_fail; } if (count > max) { printf("\nTheshold is %d, got %d, failing.\n", max, count); return 1; } else { printf("\nTheshold is %d, got %d, passing.\n", max, count); return 0; } }