#include <iostream>
#include <exception>
#include <stdexcept>

int gcd(int a, int b) {
	// Trigger to fail the test case
    if(a<0 /* || b<0 */ ) {
        throw std::invalid_argument("a and b must be negative values");
    }
    if(!(a >= 0 && b >= 0)) {
    	return -1;
    }
	if(a==0 || b==0 )
	    return a+b;
	while(a!=b) {
	    if(a>b) {
	        a = a - b;
	    }
	    else {
	        b = b - a;
	    }
	}
	return a;
}

#define expect_true(arg) \
        do { \
            if(!(arg)) { \
            	std::cout << "Unexpected false at " \
            	          << __FILE__ << ", " << __LINE__ << ", " << __func__ << ": " << #arg \
            	          << std::endl; } \
        } while(false);

void test_gcd() {
    expect_true(gcd(16,24) == 8);
    expect_true(gcd(0, 19) == 19);
    bool exceptionCaught = false;
    try {
        gcd(5, -15);
    } catch (const std::invalid_argument& ex) {
        std::cout << "Illegal as expected" << std::endl;
        exceptionCaught = true;
    }
    expect_true(exceptionCaught);
}

int main() {
	test_gcd();
	return 0;
}