Skip to content

Commit

Permalink
operators.c
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchance committed May 29, 2017
1 parent ae731c0 commit 6993d7c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 21 deletions.
21 changes: 0 additions & 21 deletions tests/compound.c

This file was deleted.

64 changes: 64 additions & 0 deletions tests/operators.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <stdio.h>
#include "tests.h"

// TODO: More comprehensive operator tests
// https://github.com/elliotchance/c2go/issues/143

int main()
{
plan(15);

int i = 10;
float f = 3.14159f;
double d = 0.0;
char c = 'A';

i %= 10;
is_eq(i, 0);

i += 10;
is_eq(i, 10);

i -= 2;
is_eq(i, 8);

i *= 2;
is_eq(i, 16);

i /= 4;
is_eq(i, 4);

i <<= 2;
is_eq(i, 16);

i >>= 2;
is_eq(i, 4);

i ^= 0xCFCF;
is_eq(i, 53195);

i |= 0xFFFF;
is_eq(i, 65535);

i &= 0x0000;
is_eq(i, 0);

diag("Other types");

f += 1.0f;
is_eq(f, 4.14159);

d += 1.25f;
is_eq(d, 1.25);

i -= 255l;
is_eq(i, -255);

i += 'A';
is_eq(i, -190);

c += 11;
is_eq(c, 76);

done_testing();
}

0 comments on commit 6993d7c

Please sign in to comment.