// File: jswaff[P]prophet3/test/utils__test.cpp
// Function: test_str_to_move()
void test_str_to_move() {
    position pos;
    reset_pos(&pos);
    move actual = str_to_move("e2e4",&pos);
    move expected = to_move(PAWN,E2,E4);

    assert(actual==expected);

    apply_move(&pos,actual,gundos);
    actual = str_to_move("g8f6",&pos);
    expected = to_move(KNIGHT,G8,F6);
    assert(actual==expected);
    apply_move(&pos,actual,gundos);

    // illegal move
    actual = str_to_move("b1d2", &pos);
    expected = BADMOVE;
    assert(actual==expected);

    // capture
    apply_move(&pos,to_move(PAWN,D2,D4),gundos);
    actual = str_to_move("f6e4",&pos);
    expected = to_capture(KNIGHT,F6,E4,PAWN);
    assert(actual==expected);
    assert(get_captured_piece(actual)==PAWN);

    // ep
    set_pos(&pos,"4k3/8/8/8/3pP3/8/7p/R3K3 b Q e3");
    actual = str_to_move("d4e3",&pos);
    expected = to_capture(PAWN,D4,E3,PAWN);
    set_epcapture(&expected);
    assert(actual==expected);
    assert(get_captured_piece(actual)==PAWN);
    apply_move(&pos,actual,gundos);

    // castle
    actual = str_to_move("e1c1",&pos);
    expected = to_move(KING,E1,C1);
    set_castle(&expected);
    assert(actual==expected);
    apply_move(&pos,actual,gundos);

    // promotion
    actual = str_to_move("h2h1r",&pos);
    expected = to_move(PAWN,H2,H1);
    set_promopiece(&expected,ROOK);
    assert(actual==expected);

    // some bogus move
    actual = str_to_move("f3f4",&pos);
    expected = BADMOVE;
    assert(actual==expected);

    //
    set_pos(&pos,"rnb1k2r/ppq1n3/2pppp2/6pp/2PP3N/P2BP3/2PB1PPP/R2Q1RK1 w kq - -");
    actual = str_to_move("h4g6",&pos);
    expected = to_move(KNIGHT,H4,G6);
    assert(actual==expected);

    set_pos(&pos,"r2r2k1/1p2p1b1/1pp1b1pp/4P2n/PP3p1p/2P2N2/5PP1/R3KBNR b KQ b3 -");
    actual = str_to_move("e6b3",&pos);
    expected = to_move(BISHOP,E6,B3);
    assert(actual==expected);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
leaq -0x1c8(%rbp), %rdi
callq 0xf390
leaq 0xe056(%rip), %rdi      # 0x41394
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x1, %edi
movl $0x34, %esi
movl $0x24, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x3337e
jmp 0x3339d
leaq 0x11672(%rip), %rdi     # 0x449f7
leaq 0x114f0(%rip), %rsi     # 0x4487c
movl $0x3c, %edx
leaq 0x11670(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xa08fe(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq 0x11662(%rip), %rdi     # 0x44a20
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x2, %edi
movl $0x6, %esi
movl $0x15, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x333fe
jmp 0x3341d
leaq 0x115f2(%rip), %rdi     # 0x449f7
leaq 0x11470(%rip), %rsi     # 0x4487c
movl $0x41, %edx
leaq 0x115f0(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xa087e(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq 0x115e7(%rip), %rdi     # 0x44a25
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movq $0x0, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x3346e
jmp 0x3348d
leaq 0x11582(%rip), %rdi     # 0x449f7
leaq 0x11400(%rip), %rsi     # 0x4487c
movl $0x47, %edx
leaq 0x11580(%rip), %rcx     # 0x44a08
callq 0x20c0
movl $0x1, %edi
movl $0x33, %esi
movl $0x23, %edx
callq 0xa830
movq %rax, %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xa07fe(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq 0x1156c(%rip), %rdi     # 0x44a2a
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x2, %edi
movl $0x15, %esi
movl $0x24, %edx
movl $0x1, %ecx
callq 0xa890
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x33503
jmp 0x33522
leaq 0x114ed(%rip), %rdi     # 0x449f7
leaq 0x1136b(%rip), %rsi     # 0x4487c
movl $0x4d, %edx
leaq 0x114eb(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rdi
callq 0xab00
cmpl $0x1, %eax
jne 0x33535
jmp 0x33554
leaq 0x114f3(%rip), %rdi     # 0x44a2f
leaq 0x11339(%rip), %rsi     # 0x4487c
movl $0x4e, %edx
leaq 0x114b9(%rip), %rcx     # 0x44a08
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x114ee(%rip), %rsi     # 0x44a50
callq 0xf3e0
leaq 0x11502(%rip), %rdi     # 0x44a70
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x1, %ecx
movl $0x23, %esi
movl $0x2c, %edx
movl %ecx, %edi
callq 0xa890
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xaa20
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x335bc
jmp 0x335db
leaq 0x11434(%rip), %rdi     # 0x449f7
leaq 0x112b2(%rip), %rsi     # 0x4487c
movl $0x55, %edx
leaq 0x11432(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rdi
callq 0xab00
cmpl $0x1, %eax
jne 0x335ee
jmp 0x3360d
leaq 0x1143a(%rip), %rdi     # 0x44a2f
leaq 0x11280(%rip), %rsi     # 0x4487c
movl $0x56, %edx
leaq 0x11400(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xa068e(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq 0x11447(%rip), %rdi     # 0x44a75
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x6, %edi
movl $0x3c, %esi
movl $0x3a, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xaa60
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x3367a
jmp 0x33699
leaq 0x11376(%rip), %rdi     # 0x449f7
leaq 0x111f4(%rip), %rsi     # 0x4487c
movl $0x5d, %edx
leaq 0x11374(%rip), %rcx     # 0x44a08
callq 0x20c0
movq -0x1d0(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq 0xa0602(%rip), %rdx     # 0xd3cb0
callq 0x3620
leaq 0x113c0(%rip), %rdi     # 0x44a7a
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x1, %edi
movl $0x37, %esi
movl $0x3f, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rdi
movl $0x4, %esi
callq 0xa9e0
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x3370b
jmp 0x3372a
leaq 0x112e5(%rip), %rdi     # 0x449f7
leaq 0x11163(%rip), %rsi     # 0x4487c
movl $0x64, %edx
leaq 0x112e3(%rip), %rcx     # 0x44a08
callq 0x20c0
leaq 0x1134f(%rip), %rdi     # 0x44a80
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movq $0x0, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x33761
jmp 0x33780
leaq 0x1128f(%rip), %rdi     # 0x449f7
leaq 0x1110d(%rip), %rsi     # 0x4487c
movl $0x69, %edx
leaq 0x1128d(%rip), %rcx     # 0x44a08
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0xd3ba(%rip), %rsi      # 0x40b48
callq 0xf3e0
leaq 0x112eb(%rip), %rdi     # 0x44a85
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x2, %edi
movl $0x27, %esi
movl $0x16, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x337da
jmp 0x337f9
leaq 0x11216(%rip), %rdi     # 0x449f7
leaq 0x11094(%rip), %rsi     # 0x4487c
movl $0x6f, %edx
leaq 0x11214(%rip), %rcx     # 0x44a08
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0xd3aa(%rip), %rsi      # 0x40bb1
callq 0xf3e0
leaq 0x11277(%rip), %rdi     # 0x44a8a
leaq -0x1c8(%rbp), %rsi
callq 0x14400
movq %rax, -0x1d0(%rbp)
movl $0x3, %edi
movl $0x14, %esi
movl $0x29, %edx
callq 0xa830
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rax
cmpq -0x1d8(%rbp), %rax
jne 0x33853
jmp 0x33872
leaq 0x1119d(%rip), %rdi     # 0x449f7
leaq 0x1101b(%rip), %rsi     # 0x4487c
movl $0x74, %edx
leaq 0x1119b(%rip), %rcx     # 0x44a08
callq 0x20c0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopl (%rax,%rax)