lunarmodules / busted

Elegant Lua unit testing.
https://lunarmodules.github.io/busted/
MIT License
1.4k stars 185 forks source link

Assert that a function returns multiple values? #576

Closed helpermethod closed 6 years ago

helpermethod commented 6 years ago

Hi,

I'm trying to test that a function returns three values, something like

local host, path, query =  parse_url(url)

But it seems assert.is_equal only accepts one argument? What's the correct way to assert that the function returns the correct result? Do I need to write a custom matcher?

Thanks you very much!

Tieske commented 6 years ago

Wrap both sides in tables. Something like this

assert.are.same( { "host-value", "path-value", "query-value" }, { parse_url(url) })
helpermethod commented 6 years ago

Thank you very much, works perfectly!