1: #include <petscsys.h> 3: static char help[] = "Test PetscComplex binary operators.\n"; 5: int main(int argc, char **argv) 6: { 7: PetscFunctionBeginUser; 8: PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 9: { 10: int i = 2; 11: float f = 2; 12: double d = 2; 13: PetscInt j = 2; 14: PetscReal r = 2; 15: PetscScalar z; 17: #define TestOps(BOP, IOP) \ 18: do { \ 19: z = i; \ 20: z = z BOP i; \ 21: z = i BOP z; \ 22: z IOP i; \ 23: (void)(z == i); \ 24: (void)(z != i); \ 25: z = f; \ 26: z = z BOP f; \ 27: z = f BOP z; \ 28: z IOP f; \ 29: (void)(z == f); \ 30: (void)(z != f); \ 31: z = d; \ 32: z = z BOP d; \ 33: z = d BOP z; \ 34: z IOP d; \ 35: (void)(z == d); \ 36: (void)(z != d); \ 37: z = j; \ 38: z = z BOP j; \ 39: z = r BOP z; \ 40: z IOP j; \ 41: (void)(z == j); \ 42: (void)(z != j); \ 43: z = r; \ 44: z = z BOP r; \ 45: z = r BOP z; \ 46: z IOP r; \ 47: (void)(z == r); \ 48: (void)(z != r); \ 49: } while (0) 51: TestOps(+, +=); 52: TestOps(-, -=); 53: TestOps(*, *=); 54: TestOps(/, /=); 55: } 56: PetscCall(PetscFinalize()); 57: return 0; 58: } 60: /*TEST 62: build: 63: requires: complex 65: test: 67: TEST*/