import operator_overload.*;
public class operator_overload_runme {
static {
System.loadLibrary("operator_overload");
}
public static void main(String argv[]) {
Op.sanity_check();
Op a = new Op();
Op b = new Op(5);
Op c = new Op(b);
Op d = new Op(2);
Op dd = d.Equal(d);
Assert(a.NotEqual(b));
Assert(b.EqualEqual(c));
Assert(a.NotEqual(d));
Assert(d.EqualEqual(dd));
Assert(a.LessThan(b));
Assert(a.LessThanEqual(b));
Assert(b.LessThanEqual(c));
Assert(b.GreaterThanEqual(c));
Assert(b.GreaterThan(d));
Assert(b.GreaterThanEqual(d));
Op e = new Op(3);
e.PlusEqual(d);
Assert(e.EqualEqual(b));
e.MinusEqual(c);
Assert(e.EqualEqual(a));
e = new Op(1);
e.MultiplyEqual(b);
Assert(e.EqualEqual(c));
e.DivideEqual(d);
Assert(e.EqualEqual(d));
e.PercentEqual(c);
Assert(e.EqualEqual(d));
Op f = new Op(1);
Op g = new Op(1);
Assert(f.Plus(g).EqualEqual(new Op(2)));
Assert(f.Minus(g).EqualEqual(new Op(0)));
Assert(f.Multiply(g).EqualEqual(new Op(1)));
Assert(f.Divide(g).EqualEqual(new Op(1)));
Assert(f.Percent(g).EqualEqual(new Op(0)));
Assert((a.Not() == true));
Assert((b.Not() == false));
Assert(a.Minus().EqualEqual(a));
Assert(b.Minus().EqualEqual( new Op(-5)));
Op h = new Op(3);
Assert(h.__getitem__(0) == 3);
Assert(h.__getitem__(1) == 0);
h.__setitem__(0,2);
Assert(h.__getitem__(0) == 2);
h.__setitem__(1,2);
Assert(h.IndexIntoConst(0) == 2);
Assert(h.IndexIntoConst(1) == 0);
Op i = new Op(3);
Assert(i.Functor()==3);
Assert(i.Functor(1)==4);
Assert(i.Functor(1,2)==6);
Op j = new Op(10);
j.PlusPlusPrefix();
j.PlusPlusPostfix(0);
Assert(j.getI() == 12);
j.MinusMinusPrefix();
j.MinusMinusPostfix(0);
Assert(j.getI() == 10);
{
Op op = j.PlusPlusPostfix(0);
Assert(j.getI() == op.getI()+1);
}
{
Op op = j.MinusMinusPostfix(0);
Assert(j.getI() == op.getI()-1);
}
Op k = new Op(3);
int check_k = k.IntCast();
Assert(check_k == 3);
Op l = new Op(4);
double check_l = l.DoubleCast();
Assert(check_l == 4);
}
public static void Assert(boolean b) {
if (!b)
throw new RuntimeException("Assertion failed");
}
}