Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test bytes with nice binary string. #47

Open
droundy opened this issue Apr 17, 2024 · 1 comment
Open

test bytes with nice binary string. #47

droundy opened this issue Apr 17, 2024 · 1 comment

Comments

@droundy
Copy link

droundy commented Apr 17, 2024

I'd love to be able to write something like

expect_test::expect_bytes![b"hello world\x83"].expect(bytes);

and have UPDATE_EXPECT=1 update the byte string to be something reasonably readable, and to give me pretty diffs for "mostly text" binary data.

@xxchan
Copy link

xxchan commented May 16, 2024

I think you should write your own fn bytes_to_some_reasonable_str(bytes) -> String, and then expect![["str"]].assert_eq(bytes_to_some_reasonable_str(bytes))

BTW there's a pattern:

fn check(expect: Expect, input: T) {
    let str = do_something_to_get_a_result_str(input);
	expect.assert_eq(str);
} 

check(expect![], x);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants