updated tests
This commit is contained in:
parent
bb3bc4442a
commit
f9dda928b2
39
src/main.zig
39
src/main.zig
@ -65,7 +65,7 @@ fn uci(str: []const u8, game: *c.game, alloc: std.mem.Allocator) uciRet {
|
|||||||
return .{ .pass = {} };
|
return .{ .pass = {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uciPos(str: []const u8, alloc: std.mem.Allocator) [*c]c.game {
|
fn uciPos(str: []const u8, alloc: std.mem.Allocator) *c.game {
|
||||||
const pos = std.mem.indexOfAny(u8, str, " \t\n\r") orelse str.len;
|
const pos = std.mem.indexOfAny(u8, str, " \t\n\r") orelse str.len;
|
||||||
const tok = str[0..pos];
|
const tok = str[0..pos];
|
||||||
var game = fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
var game = fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
@ -112,25 +112,46 @@ fn uciGo(game: *c.game) []const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "uci uci" {
|
test "uci uci" {
|
||||||
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const out = uci("uci", game);
|
defer _ = gpa.deinit();
|
||||||
|
const alloc = gpa.allocator();
|
||||||
|
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
|
defer alloc.destroy(game);
|
||||||
|
|
||||||
|
const out = uci("uci", game, alloc);
|
||||||
try std.testing.expect(out == .text);
|
try std.testing.expect(out == .text);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "uci ready" {
|
test "uci ready" {
|
||||||
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const out = uci("isready", game);
|
defer _ = gpa.deinit();
|
||||||
|
const alloc = gpa.allocator();
|
||||||
|
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
|
defer alloc.destroy(game);
|
||||||
|
|
||||||
|
const out = uci("isready", game, alloc);
|
||||||
try std.testing.expect(out == .text);
|
try std.testing.expect(out == .text);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "uci go" {
|
test "uci go" {
|
||||||
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const out = uci("go", game);
|
defer _ = gpa.deinit();
|
||||||
|
const alloc = gpa.allocator();
|
||||||
|
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
|
defer alloc.destroy(game);
|
||||||
|
|
||||||
|
const out = uci("go", game, alloc);
|
||||||
try std.testing.expect(out == .move);
|
try std.testing.expect(out == .move);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "uci position" {
|
test "uci position" {
|
||||||
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const out = uci("position startpos", game);
|
defer _ = gpa.deinit();
|
||||||
|
const alloc = gpa.allocator();
|
||||||
|
const game = uciPos("fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
|
defer alloc.destroy(game);
|
||||||
|
|
||||||
|
const out = uci("position startpos", game, alloc);
|
||||||
try std.testing.expect(out == .game);
|
try std.testing.expect(out == .game);
|
||||||
|
alloc.destroy(out.game);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user