コード例 #1
0
ファイル: CSSTest.cpp プロジェクト: radiosity/libepub
TEST(CSSTest, Selector_Count)
{

	CSSSelector test_a("p");

	ASSERT_EQ(1, test_a.count());

	CSSSelector test_b("h1, h2, h3");

	ASSERT_EQ(3, test_b.count());

	CSSSelector test_c("p span");

	ASSERT_EQ(1, test_c.count());

	CSSSelector test_d("p.section");

	ASSERT_EQ(1, test_d.count());

	CSSSelector test_e(".bold");

	ASSERT_EQ(1, test_e.count());

	CSSSelector test_f("#id");

	ASSERT_EQ(1, test_f.count());

}
コード例 #2
0
ファイル: funcs_tests.c プロジェクト: bsugiarto24/CPE-101
void test_cases(void)
{
   test_square();
   test_f();
   test_g();
   test_hypotenuse();
   test_is_positive();
}
コード例 #3
0
ファイル: test.c プロジェクト: ecology-rocks/SortieND
int
main (void)
{
  gsl_function F_cos, F_func1, F_func2, F_func3, F_func4;
  
  const gsl_min_fminimizer_type * fminimizer[4] ;
  const gsl_min_fminimizer_type ** T;

  gsl_ieee_env_setup ();

  fminimizer[0] = gsl_min_fminimizer_goldensection;
  fminimizer[1] = gsl_min_fminimizer_brent;
  fminimizer[2] = 0;

  F_cos = create_function (f_cos) ;
  F_func1 = create_function (func1) ;
  F_func2 = create_function (func2) ;
  F_func3 = create_function (func3) ;
  F_func4 = create_function (func4) ;

  gsl_set_error_handler (&my_error_handler);

  for (T = fminimizer ; *T != 0 ; T++)
    {
      test_f (*T, "cos(x) [0 (3) 6]", &F_cos, 0.0, 3.0, 6.0, M_PI);
      test_f (*T, "x^4 - 1 [-3 (-1) 17]", &F_func1, -3.0, -1.0, 17.0, 0.0);
      test_f (*T, "sqrt(|x|) [-2 (-1) 1.5]", &F_func2, -2.0, -1.0, 1.5, 0.0);
      test_f (*T, "func3(x) [-2 (3) 4]", &F_func3, -2.0, 3.0, 4.0, 1.0);
      test_f (*T, "func4(x) [0 (0.782) 1]", &F_func4, 0, 0.782, 1.0, 0.8);

      test_f_e (*T, "invalid range check [4, 0]", &F_cos, 4.0, 3.0, 0.0, M_PI);
      test_f_e (*T, "invalid range check [1, 1]", &F_cos, 1.0, 1.0, 1.0, M_PI);
      test_f_e (*T, "invalid range check [-1, 1]", &F_cos, -1.0, 0.0, 1.0, M_PI);
    }
  test_bracket("cos(x) [1,2]",&F_cos,1.0,2.0,15);
  test_bracket("sqrt(|x|) [-1,0]",&F_func2,-1.0,0.0,15);
  test_bracket("sqrt(|x|) [-1,-0.6]",&F_func2,-1.0,-0.6,15);
  test_bracket("sqrt(|x|) [-1,1]",&F_func2,-1.0,1.0,15);

  exit (gsl_test_summary ());
}
コード例 #4
0
ファイル: CSSTest.cpp プロジェクト: radiosity/libepub
TEST(CSSTest, Selector_Specificity)
{

	CSSSelector selector_a("p");
	CSSSpecificity test_a(0, 0, 0, 1);

	ASSERT_TRUE(selector_a.specificity == test_a);

	CSSSelector selector_b("h1, h2, h3");
	CSSSpecificity test_b(0, 0, 0, 3);

	ASSERT_TRUE(selector_b.specificity == test_b);

	/*
	CSSSelector test_c("p span");

	ASSERT_EQ(1, test_c.count());
	*/

	CSSSelector selector_d("p.section");
	CSSSpecificity test_d(0, 0, 1, 1);

	ASSERT_TRUE(selector_d.specificity == test_d);

	CSSSelector selector_e(".bold");
	CSSSpecificity test_e(0, 0, 1, 0);

	ASSERT_TRUE(selector_e.specificity == test_e);

	CSSSelector selector_f("#id");
	CSSSpecificity test_f(0, 1, 0, 0);

	ASSERT_TRUE(selector_f.specificity == test_f);

	CSSSelector selector_g("span#id");
	CSSSpecificity test_g(0, 1, 0, 1);

	ASSERT_TRUE(selector_g.specificity == test_g);

	CSSSelector selector_h("span#id, p.hello, br");
	CSSSpecificity test_h(0, 1, 1, 3);

	ASSERT_TRUE(selector_h.specificity == test_h);

}
コード例 #5
0
ファイル: CSSTest.cpp プロジェクト: radiosity/libepub
TEST(CSSTest, Selector_Matches)
{

	CSSSelector test_a("p");

	ASSERT_TRUE(test_a.matches("p"));

	CSSSelector test_b("h1, h2, h3");

	ASSERT_TRUE(test_b.matches("h1"));
	ASSERT_TRUE(test_b.matches("h2"));
	ASSERT_TRUE(test_b.matches("h3"));

	/*
	CSSSelector test_c("p span");

	ASSERT_EQ(1, test_c.count());
	*/

	CSSSelector test_d("p.section");

	ASSERT_TRUE(test_d.matches("p.section"));

	CSSSelector test_e(".bold");

	ASSERT_TRUE(test_e.matches(".bold"));

	CSSSelector test_f("#id");

	ASSERT_TRUE(test_f.matches("#id"));

	CSSSelector test_g("span#id");

	ASSERT_TRUE(test_g.matches("span#id"));


}
コード例 #6
0
ファイル: test.c プロジェクト: Ayato-Harashima/CMVS-PMVS
int
main (void)
{
  gsl_function F_sin, F_cos, F_func1, F_func2, F_func3, F_func4,
    F_func5, F_func6;
  
  gsl_function_fdf FDF_sin, FDF_cos, FDF_func1, FDF_func2, FDF_func3, FDF_func4,
    FDF_func5, FDF_func6;

  const gsl_root_fsolver_type * fsolver[4] ;
  const gsl_root_fdfsolver_type * fdfsolver[4] ;

  const gsl_root_fsolver_type ** T;
  const gsl_root_fdfsolver_type ** S;

  gsl_ieee_env_setup();

  fsolver[0] = gsl_root_fsolver_bisection;
  fsolver[1] = gsl_root_fsolver_brent;
  fsolver[2] = gsl_root_fsolver_falsepos;
  fsolver[3] = 0;

  fdfsolver[0] = gsl_root_fdfsolver_newton;
  fdfsolver[1] = gsl_root_fdfsolver_secant;
  fdfsolver[2] = gsl_root_fdfsolver_steffenson;
  fdfsolver[3] = 0;

  F_sin = create_function (sin_f) ;
  F_cos = create_function (cos_f) ; 
  F_func1 = create_function (func1) ;
  F_func2 = create_function (func2) ;
  F_func3 = create_function (func3) ;
  F_func4 = create_function (func4) ;
  F_func5 = create_function (func5) ;
  F_func6 = create_function (func6) ;

  FDF_sin = create_fdf (sin_f, sin_df, sin_fdf) ;
  FDF_cos = create_fdf (cos_f, cos_df, cos_fdf) ;
  FDF_func1 = create_fdf (func1, func1_df, func1_fdf) ;
  FDF_func2 = create_fdf (func2, func2_df, func2_fdf) ;
  FDF_func3 = create_fdf (func3, func3_df, func3_fdf) ;
  FDF_func4 = create_fdf (func4, func4_df, func4_fdf) ;
  FDF_func5 = create_fdf (func5, func5_df, func5_fdf) ;
  FDF_func6 = create_fdf (func6, func6_df, func6_fdf) ;

  gsl_set_error_handler (&my_error_handler);

  for (T = fsolver ; *T != 0 ; T++)
    {
      test_f (*T, "sin(x) [3, 4]", &F_sin, 3.0, 4.0, M_PI);
      test_f (*T, "sin(x) [-4, -3]", &F_sin, -4.0, -3.0, -M_PI);
      test_f (*T, "sin(x) [-1/3, 1]", &F_sin, -1.0 / 3.0, 1.0, 0.0);
      test_f (*T, "cos(x) [0, 3]", &F_cos, 0.0, 3.0, M_PI / 2.0);
      test_f (*T, "cos(x) [-3, 0]", &F_cos, -3.0, 0.0, -M_PI / 2.0);
      test_f (*T, "x^20 - 1 [0.1, 2]", &F_func1, 0.1, 2.0, 1.0);
      test_f (*T, "sqrt(|x|)*sgn(x)", &F_func2, -1.0 / 3.0, 1.0, 0.0);
      test_f (*T, "x^2 - 1e-8 [0, 1]", &F_func3, 0.0, 1.0, sqrt (1e-8));
      test_f (*T, "x exp(-x) [-1/3, 2]", &F_func4, -1.0 / 3.0, 2.0, 0.0);
      test_f (*T, "(x - 1)^7 [0.9995, 1.0002]", &F_func6, 0.9995, 1.0002, 1.0);
      
      test_f_e (*T, "invalid range check [4, 0]", &F_sin, 4.0, 0.0, M_PI);
      test_f_e (*T, "invalid range check [1, 1]", &F_sin, 1.0, 1.0, M_PI);
      test_f_e (*T, "invalid range check [0.1, 0.2]", &F_sin, 0.1, 0.2, M_PI);
    }

  for (S = fdfsolver ; *S != 0 ; S++)
    {
      test_fdf (*S,"sin(x) {3.4}", &FDF_sin, 3.4, M_PI);
      test_fdf (*S,"sin(x) {-3.3}", &FDF_sin, -3.3, -M_PI);
      test_fdf (*S,"sin(x) {0.5}", &FDF_sin, 0.5, 0.0);
      test_fdf (*S,"cos(x) {0.6}", &FDF_cos, 0.6, M_PI / 2.0);
      test_fdf (*S,"cos(x) {-2.5}", &FDF_cos, -2.5, -M_PI / 2.0);
      test_fdf (*S,"x^{20} - 1 {0.9}", &FDF_func1, 0.9, 1.0);
      test_fdf (*S,"x^{20} - 1 {1.1}", &FDF_func1, 1.1, 1.0);
      test_fdf (*S,"sqrt(|x|)*sgn(x) {1.001}", &FDF_func2, 0.001, 0.0);
      test_fdf (*S,"x^2 - 1e-8 {1}", &FDF_func3, 1.0, sqrt (1e-8));
      test_fdf (*S,"x exp(-x) {-2}", &FDF_func4, -2.0, 0.0);
      test_fdf_e (*S,"max iterations x -> +Inf, x exp(-x) {2}", &FDF_func4, 2.0, 0.0);
      test_fdf_e (*S,"max iterations x -> -Inf, 1/(1 + exp(-x)) {0}", &FDF_func5, 0.0, 0.0);
    }

  test_fdf (gsl_root_fdfsolver_steffenson,
            "(x - 1)^7 {0.9}", &FDF_func6, 0.9, 1.0);    

  /* now summarize the results */

  exit (gsl_test_summary ());
}
コード例 #7
0
ファイル: test.c プロジェクト: BrianGladman/gsl
int
main (void)
{
  gsl_ieee_env_setup ();

  {
    const gsl_multimin_fdfminimizer_type *fdfminimizers[6];
    const gsl_multimin_fdfminimizer_type ** T;

    fdfminimizers[0] = gsl_multimin_fdfminimizer_steepest_descent;
    fdfminimizers[1] = gsl_multimin_fdfminimizer_conjugate_pr;
    fdfminimizers[2] = gsl_multimin_fdfminimizer_conjugate_fr;
    fdfminimizers[3] = gsl_multimin_fdfminimizer_vector_bfgs;
    fdfminimizers[4] = gsl_multimin_fdfminimizer_vector_bfgs2;
    fdfminimizers[5] = 0;

    T = fdfminimizers;
    
    while (*T != 0) 
      {
        test_fdf("Roth", &roth, roth_initpt,*T);
        test_fdf("Wood", &wood, wood_initpt,*T);
        test_fdf("Rosenbrock", &rosenbrock, rosenbrock_initpt,*T);
        test_fdf("Rosenbrock1", &rosenbrock, rosenbrock_initpt1,*T);
        test_fdf("SimpleAbs", &simpleabs, simpleabs_initpt,*T);
        T++;
      }
    
    T = fdfminimizers;
    
    while (*T != 0) 
      {
        test_fdf("NRoth", &Nroth, roth_initpt,*T);
        test_fdf("NWood", &Nwood, wood_initpt,*T);
        test_fdf("NRosenbrock", &Nrosenbrock, rosenbrock_initpt,*T);
        T++;
      }
  }


  {
    const gsl_multimin_fminimizer_type *fminimizers[4];
    const gsl_multimin_fminimizer_type ** T;

    fminimizers[0] = gsl_multimin_fminimizer_nmsimplex;
    fminimizers[1] = gsl_multimin_fminimizer_nmsimplex2;
    fminimizers[2] = gsl_multimin_fminimizer_nmsimplex2rand;
    fminimizers[3] = 0;
    
    T = fminimizers;
    
    while (*T != 0) 
      {
        test_f("Roth", &roth_fmin, roth_initpt,*T);
        test_f("Wood", &wood_fmin, wood_initpt,*T);
        test_f("Rosenbrock", &rosenbrock_fmin, rosenbrock_initpt,*T);
        test_f("Spring", &spring_fmin, spring_initpt,*T);
        T++;
      }
  }


  exit (gsl_test_summary());
}
コード例 #8
0
void floats(float x) {
    test_f(x * 1.0);  // no-warning
    test_f(x * 1.0F); // no-warning
}
コード例 #9
0
int
main (void)
{
    const gsl_multiroot_fsolver_type * fsolvers[5] ;
    const gsl_multiroot_fsolver_type ** T1 ;

    const gsl_multiroot_fdfsolver_type * fdfsolvers[5] ;
    const gsl_multiroot_fdfsolver_type ** T2 ;

    double f;

    fsolvers[0] = gsl_multiroot_fsolver_dnewton;
    fsolvers[1] = gsl_multiroot_fsolver_broyden;
    fsolvers[2] = gsl_multiroot_fsolver_hybrid;
    fsolvers[3] = gsl_multiroot_fsolver_hybrids;
    fsolvers[4] = 0;

    fdfsolvers[0] = gsl_multiroot_fdfsolver_newton;
    fdfsolvers[1] = gsl_multiroot_fdfsolver_gnewton;
    fdfsolvers[2] = gsl_multiroot_fdfsolver_hybridj;
    fdfsolvers[3] = gsl_multiroot_fdfsolver_hybridsj;
    fdfsolvers[4] = 0;

    gsl_ieee_env_setup();


    f = 1.0 ;

    T1 = fsolvers ;

    while (*T1 != 0)
    {
        test_f ("Rosenbrock", &rosenbrock, rosenbrock_initpt, f, *T1);
        test_f ("Roth", &roth, roth_initpt, f, *T1);
        test_f ("Powell badly scaled", &powellscal, powellscal_initpt, f, *T1);
        test_f ("Brown badly scaled", &brownscal, brownscal_initpt, f, *T1);
        test_f ("Powell singular", &powellsing, powellsing_initpt, f, *T1);
        test_f ("Wood", &wood, wood_initpt, f, *T1);
        test_f ("Helical", &helical, helical_initpt, f, *T1);
        test_f ("Discrete BVP", &dbv, dbv_initpt, f, *T1);
        test_f ("Trig", &trig, trig_initpt, f, *T1);
        T1++;
    }

    T2 = fdfsolvers ;

    while (*T2 != 0)
    {
        test_fdf ("Rosenbrock", &rosenbrock, rosenbrock_initpt, f, *T2);
        test_fdf ("Roth", &roth, roth_initpt, f, *T2);
        test_fdf ("Powell badly scaled", &powellscal, powellscal_initpt, f, *T2);
        test_fdf ("Brown badly scaled", &brownscal, brownscal_initpt, f, *T2);
        test_fdf ("Powell singular", &powellsing, powellsing_initpt, f, *T2);
        test_fdf ("Wood", &wood, wood_initpt, f, *T2);
        test_fdf ("Helical", &helical, helical_initpt, f, *T2);
        test_fdf ("Discrete BVP", &dbv, dbv_initpt, f, *T2);
        test_fdf ("Trig", &trig, trig_initpt, f, *T2);
        T2++;
    }

    exit (gsl_test_summary ());
}