module tb_scorehand();
	logic err;
	logic [3:0] card1, card2, card3, total;
	scorehand DUT(card1, card2, card3, total);

	task check;
		input logic [3:0] expected;
		if (total !== expected) begin
			err = 1;
			$display("FAILED: total is incorrect.");
		end
	endtask: check;

	initial begin
		#10000;
		$stop;
	end

	initial begin
		err = 0;

		/* (9 + 9 + 9) % 10 = 7. */

		$display("Test 1");
		card1 = 4'd9;
		card2 = 4'd9;
		card3 = 4'd9;
		#5;
		check(4'd7);
		#5;

		/* (9 + 9 + 0) % 10 = 8. */

		$display("Test 2");
		card1 = 4'd9;
		card2 = 4'd9;
		card3 = 4'd0;
		#5;
		check(4'd8);
		#5;

		/* (T + K + A) % 10 = 1. */

		$display("Test 3");
		card1 = 4'd10;
		card2 = 4'd13;
		card3 = 4'd1;
		#5;
		check(4'd1);
		#5;

		/* (J + Q + K) % 10 = 0. */

		$display("Test 4");
		card1 = 4'd11;
		card2 = 4'd12;
		card3 = 4'd13;
		#5;
		check(4'd0);
		#5;

		/* (A + 2 + 3) % 10 = 6. */

		$display("Test 5");
		card1 = 4'd1;
		card2 = 4'd2;
		card3 = 4'd3;
		#5;
		check(4'd6);
		#5;

		/* (9 + 0 + 0) % 10 = 9. */

		$display("Test 6");
		card1 = 4'd9;
		card2 = 4'd0;
		card3 = 4'd0;
		#5;
		check(4'd9);
		#5;

		/* (9 + T + 0) % 10 = 9. */

		$display("Test 7");
		card1 = 4'd9;
		card2 = 4'd10;
		card3 = 4'd0;
		#5;
		check(4'd9);
		#5;

		/* (9 + A + 0) % 10 = 0. */

		$display("Test 8");
		card1 = 4'd9;
		card2 = 4'd1;
		card3 = 4'd0;
		#5;
		check(4'd0);
		#5;

		if (~err)
			$display("All tests passed.");

		#10;
		$stop;
	end
endmodule: tb_scorehand
