Beispiel #1
0
TEST(Result, inspect)
{
    struct Foo
    {
        int val;

        Foo(int v) : val(v) {}
        Foo(Foo&&) = default;
        Foo(const Foo&) = delete;
        Foo& operator = (Foo&&) = default;
        Foo& operator = (const Foo&) = delete;

        bool operator == (const Foo& other) const
        {
            return this->val == other.val;
        }
    };

    Result<Foo> foo = Ok(Foo(1));
    EXPECT_TRUE(foo.is_ok());
    EXPECT_FALSE(foo.is_err());
    EXPECT_EQ(foo.get_success(), Some(Foo(1)));
    EXPECT_EQ(foo.get_failure(), ""_s);
    foo = Err("oops"_s);
    EXPECT_FALSE(foo.is_ok());
    EXPECT_TRUE(foo.is_err());
    EXPECT_EQ(foo.get_success(), None<Foo>());
    EXPECT_EQ(foo.get_failure(), "oops"_s);
}
Beispiel #2
0
TEST( Hit_Check_Test, CircleHit ){
	
	wing::DefaltLoader Loader;
	auto img = Loader.load();

	{
		TestSprite Hoge(60,60,img,wing::Position(-10,20));
		TestSprite Foo(80,80,img,wing::Position(80,-10));
		ASSERT_EQ(wing::sprite::checkRectHit(Hoge, Hoge) , false);

		ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , false);
	}

	{
		TestSprite Hoge(60,60,img,wing::Position(-0,0));
		TestSprite Foo(80,80,img,wing::Position(20,0));

		ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , true);
	}

	{
		TestSprite Hoge(60,60,img,wing::Position(0,0));
		TestSprite Foo(80,80,img,wing::Position(70,0));

		ASSERT_EQ(wing::sprite::checkCircleHit(Hoge, Foo) , false);
	}

}
Beispiel #3
0
testing::AssertionResult AssertFoo(const char* m_expr, const char* n_expr, const char* k_expr, int m, int n, int k) {
    if (Foo(m, n) == k)
        return testing::AssertionSuccess();
    testing::Message msg;
    msg << m_expr << " 和 " << n_expr << " 的最大公约数应该是:" << Foo(m, n) << " 而不是:" << k_expr;
    return testing::AssertionFailure(msg);
}
Beispiel #4
0
int64_t decode(void *buffer, size_t size, int64_t sum)
{
    unsigned int i;
    C(table_t) foobarcontainer;
    FooBar(vec_t) list;
    FooBar(table_t) foobar;
    Bar(struct_t) bar;
    Foo(struct_t) foo;

    foobarcontainer = C(as_root(buffer));
    sum += C(initialized(foobarcontainer));
    sum += StringLen(C(location(foobarcontainer)));
    sum += C(fruit(foobarcontainer));
    list = C(list(foobarcontainer));
    for (i = 0; i < FooBar(vec_len(list)); ++i) {
        foobar = FooBar(vec_at(list, i));
        sum += StringLen(FooBar(name(foobar)));
        sum += FooBar(postfix(foobar));
        sum += (int64_t)FooBar(rating(foobar));
        bar = FooBar(sibling(foobar));
        sum += (int64_t)Bar(ratio(bar));
        sum += Bar(size(bar));
        sum += Bar(time(bar));
        foo = Bar(parent(bar));
        sum += Foo(count(foo));
        sum += Foo(id(foo));
        sum += Foo(length(foo));
        sum += Foo(prefix(foo));
    }
    return sum + 2 * sum;
}
void Test2() {
  // CHECK-DTOR-LABEL: Test2
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR1:[0-9]+]])
  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR2:[0-9]+]])
  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR2]])
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR1]])
  // CHECK-DTOR: }

  // CHECK-NO-DTOR-LABEL: Test2
  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR1:[0-9]+]])
  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR2:[0-9]+]])
  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR2]])
  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR1]])
  // CHECK-NO-DTOR: }
  const A &a = A{};
  Foo(a);
  const A &b = A{};
  Foo(b);
}
void Test1() {
  // CHECK-DTOR-LABEL: Test1
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: }

  // CHECK-NO-DTOR-LABEL: Test1
  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-NO-DTOR: }
  {
    const A &a = A{};
    Foo(a);
  }
  {
    const A &a = A{};
    Foo(a);
  }
}
Beispiel #7
0
TEST(FooTest, HandleNoneZeroInput)

{

	EXPECT_EQ(2, Foo(4, 10));

	EXPECT_EQ(6, Foo(30, 18));

}
Beispiel #8
0
		void UserTypeInContainer(YAML::Emitter& out, std::string& desiredOutput)
		{
			std::vector<Foo> fv;
			fv.push_back(Foo(5, "hello"));
			fv.push_back(Foo(3, "goodbye"));
			out << fv;
			
			desiredOutput = "- x: 5\n  bar: hello\n- x: 3\n  bar: goodbye";
		}
Beispiel #9
0
int main()
{
    Foo( 12, 345, 678, 90 );
    Foo( 11, 22, 33, 44 );
    Foo( 99, 88, 77, 66 );

    return 0;
    
}
Beispiel #10
0
void foo()
{
  std::cout << "========== Foo ==============\n";

  Foo foo = Foo() + Foo();

  std::cout << "=============================\n";

}
Beispiel #11
0
		void UserType(YAML::Emitter& out, std::string& desiredOutput)
		{
			out << YAML::BeginSeq;
			out << Foo(5, "hello");
			out << Foo(3, "goodbye");
			out << YAML::EndSeq;
			
			desiredOutput = "- x: 5\n  bar: hello\n- x: 3\n  bar: goodbye";
		}
Beispiel #12
0
void Bar(T... t)
{
    Foo(t...); // invokes Foo once with all arguments in the pack
    
    std::cout << "------------------\n";
    
    using swallow = int[];
    void(swallow{0, (void(Foo(t)), 0)...}); // invokes Foo once for each argument in the pack
}
Beispiel #13
0
int main()
{
   Foo({}, {});   // Foo(int = 0, int = 0)
   Foo({1}, {2}); // Foo(int = 1, int = 2)
   Foo({1, 2});   // Foo(int = 1, int = 2)

   bar({}, {});   // bar(int = 0, int = 0)
   bar({1}, {2}); // bar(int = 1, int = 2)
   bar({1, 2});   // error: no matching function for call to 'bar'  <<< Why? <<<
}
Beispiel #14
0
int main(int argc, char** argv)
{
    unsigned long int num;

    puts("Enter the number:");
    scanf("%lu",&num);

    printf("%lu",Foo(num));     // Виклик функції
    PrintBinary(num);		// Друк (2 код) аргумента
    PrintBinary(Foo(num));	// Друк (2 код) результату
    return 0;
}
Beispiel #15
0
int main(int argc, char** argv)
{
    unsigned long int num;

    puts("Enter the number:");
    scanf("%lu",&num);

    printf("%lu",Foo(num));     // Виклик ф-ції Foo
    PrintBinary(num);
    PrintBinary(Foo(num));
	return 0;
}
Beispiel #16
0
int main(int argc, char** argv)
{
    unsigned long int num;

    puts("Enter the number:");
    scanf("%ld",&num);

    printf("%ld",Foo(num));     // Виклик ф-ції Foo
    PrintBinary(num);		// Друк (2 код) аргумента
    PrintBinary(Foo(num));	// Друк (2 код) результату
	return 0;
}
void Test6() {
  // CHECK-DTOR-LABEL: Test6
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 {{[0-9]+}}, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call i32 @_Z3BazIiET_v()
  // CHECK-DTOR: store
  // CHECK-DTOR: call void @_Z3FooIiEvOT_
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 {{[0-9]+}}, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 {{[0-9]+}}, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call i32 @_Z3BazIiET_v()
  // CHECK-DTOR: store
  // CHECK-DTOR: call void @_Z3FooIiEvOT_
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 {{[0-9]+}}, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: }
  Foo(Baz<int>());
  Foo(Baz<int>());
}
Beispiel #18
0
int main()
{

    std::vector<Foo> vFoo;

    for(int i = 0; i < 100; ++i)
        vFoo.push_back(Foo());

    for(auto it = vFoo.begin(); it != vFoo.end(); ++it)
        std::cout << *it << " ";   
    std::cout << std::endl;

    std::sort(vFoo.begin(), vFoo.end(), greater);

    for(auto it = vFoo.begin(); it != vFoo.end(); ++it)
        std::cout << *it << " ";   
    std::cout << std::endl;

    std::sort(vFoo.begin(), vFoo.end());

    for(auto it = vFoo.begin(); it != vFoo.end(); ++it)
        std::cout << *it << " ";   
    std::cout << std::endl;

    std::sort(vFoo.begin(), vFoo.end(), FooComparator());

    for(auto it = vFoo.begin(); it != vFoo.end(); ++it)
        std::cout << *it << " ";   
    std::cout << std::endl;
    std::cout << std::endl;


    return 0;
}
Beispiel #19
0
int main(int argc, char **argv) {
	Foo f = Foo();
	A a = A();
	f.bar(5);
	a.c();
	return 0;
}
Beispiel #20
0
//  TODO: Can use dynamic scheduling here
int BuildNeigh( void* arg, int id ) {
  double rd, cutoffSquare;
  int    i,j;

  cutoffSquare  = (cutoffRadius * TOLERANCE)*(cutoffRadius * TOLERANCE);

  for (i = (numMoles / NTHREADS) * id; i < (numMoles / NTHREADS) * (id + 1); ++i) {
    for (j = i+1; j<numMoles; j++ ) {
    	rd = Foo ( (double)x[IND(0,i)], (double)x[IND(1,i)], (double)x[IND(2,i)],
    	           (double)x[IND(0,j)], (double)x[IND(1,j)], (double)x[IND(2,j)]);

      if (rd > cutoffSquare) {
        continue;
      }

      BEGIN_TRANSACTION();

      //printf("APP: writing i: %x (%x), with value: %d\n", &inter[INDX(ninter,0)], &(inter[INDX(ninter,0)]._value), i);
      inter[INDX(ninter,0)] = i;
      //printf("APP: writing j: %x (%x), with value: %d\n", &inter[INDX(ninter,1)], &(inter[INDX(ninter,1)]._value), j);
      inter[INDX(ninter,1)] = j;
      ++ninter;

      COMMIT_TRANSACTION();

      if ( ninter >= MAXINTERACT) {
        perror("MAXINTERACT limit");
      }
    }
  }

  return 0;
}
int main() {
  Foo* Pointer = 0;                   // CHECK: Bar *Pointer = 0;
  Foo Variable = Foo(10);             // CHECK: Bar Variable = Bar(10);
  for (Foo it; it < Variable; it++) { // for (Bar it; it < Variable; it++) {}
  }
  return 0;
}
Beispiel #22
0
int main ()
{
  static int const cs = 1;
  static int const ca[1] = {1};
  static int s = 1;
  static int a[1] = {1};
  
  Foo (&cs);
  Foo (&ca);
  if (Foo (&s) != 2)
    return 1;
  if (Foo (&a) != 2)
    return 2;
  
  return 0;
}
void Test7() {
  // CHECK-DTOR-LABEL: Test7
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call void @_Z3BazI1AET_v({{.*}} %[[SLOT:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooI1AEvOT_({{.*}} %[[SLOT]])
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[SLOT]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* nonnull %[[ADDR:[0-9]+]])
  // CHECK-DTOR: call void @_Z3BazI1AET_v({{.*}} %[[SLOT:[^ ]+]])
  // CHECK-DTOR: call void @_Z3FooI1AEvOT_({{.*}} %[[SLOT]])
  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[SLOT]])
  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* nonnull %[[ADDR]])
  // CHECK-DTOR: }
  Foo(Baz<A>());
  Foo(Baz<A>());
}
Beispiel #24
0
int t9(int n) {
  // Make sure the error works in potentially-evaluated sizeof
  return (int)sizeof(*(Helper(Foo()), (int (*)[n])0));
#if __cplusplus <= 199711L
  // expected-warning@-2 {{cannot pass object of non-POD type 'Foo' through variadic function; call will abort at runtime}}
#endif
}
Beispiel #25
0
int
main()
{
    static int size1 = 20;
    static int size2 = 40;
    char buf[size1], buf2[size2];
    char buf3[SIZE1], buf4[SIZE2];
    char (*buf5)[SIZE2];
    char* buf6[SIZE2];
    char *buf7[SIZE2];
    snprintf(buf, 20, "%s", "hello world");
    snprintf(buf2, 40, "%s", "hello world2");
    Foo(buf);
    Foo(buf2);
	return 0;
}
Beispiel #26
0
TEST_F(ClassBinderTest, BoundName)
{
	elba::reference x(state);
	x = Foo();
	EXPECT_EQ(1, Foo::count_constructed);
	EXPECT_EQ("Foo", x.metatable()["name"]);
}
Beispiel #27
0
TEST( Hit_Check_Test, RectHit ){

	wing::DefaltLoader Loader;
	auto img = Loader.load();

	TestSprite Hoge(100,100,img);

	TestSprite Foo(50,80,img);
	ASSERT_EQ(wing::sprite::checkRectHit(Hoge,Foo) , true);
	ASSERT_EQ(wing::sprite::checkRectHit(Foo,Hoge) , true);


	TestSprite Foo2(50,80,img,wing::Position(80,80) );
	ASSERT_EQ(wing::sprite::checkRectHit(Hoge,Foo2) , true);
	ASSERT_EQ(wing::sprite::checkRectHit(Foo2,Hoge) , true);

	
	TestSprite Foo3(50,80,img,wing::Position(100,80));
	ASSERT_EQ(wing::sprite::checkRectHit(Hoge,Foo3) , false);
	ASSERT_EQ(wing::sprite::checkRectHit(Foo3,Hoge) , false);


	TestSprite Foo4(50,80,img,wing::Position(80,120));
	ASSERT_EQ(wing::sprite::checkRectHit(Hoge,Foo3) , false);
	ASSERT_EQ(wing::sprite::checkRectHit(Foo3,Hoge) , false);

}
Beispiel #28
0
TEST_F(JsValueTest, ObjectValue)
{
  const std::string source("\
    function Foo() {\
      this.x = 2;\
      this.toString = function() {return 'foo';};\
      this.valueOf = function() {return 123;};\
    };\
Beispiel #29
0
int main(){
    int i = 1;
    i = 1;
    while(i < 0)
        i++;
    i = Foo(Bar()) + 5;
    return 0;
}
Beispiel #30
0
int
main()
{
  B b;
  Foo(b);

  printf ("PASS\n");
}