diff options
| author | Augustin Gottlieb <33221555+aguspe@users.noreply.github.com> | 2026-01-02 17:54:42 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-04 06:56:57 +0000 |
| commit | 912cf819b96a7ada89db044add26e94746f3ebb5 (patch) | |
| tree | 26192aaff3ebee6424c8014c801acac78df9153f /test | |
| parent | ca0fece56a3ddfa6b9ec9cf1652e414929040614 (diff) | |
[ruby/openssl] Improve Argument Error Message in EC:Group.new
Before, passing the wrong number of arguments (e.g., 2) to
OpenSSL::PKey::EC::Group.new raised a generic "wrong number of
arguments"
error.
This change updates it to show the actual argument count and the
expected
options (1 or 4), making debugging easier for the user.
Example:
ArgumentError: wrong number of arguments (given 2, expected 1 or 4)
I hope it helps!
https://github.com/ruby/openssl/commit/783c99e6c7
Diffstat (limited to 'test')
| -rw-r--r-- | test/openssl/test_pkey_ec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_ec.rb b/test/openssl/test_pkey_ec.rb index 88085bc68c..ec97a747a3 100644 --- a/test/openssl/test_pkey_ec.rb +++ b/test/openssl/test_pkey_ec.rb @@ -345,6 +345,15 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase assert_equal group1.degree, group4.degree end + def test_ec_group_initialize_error_message + # Test that passing 2 arguments raises the helpful error + e = assert_raise(ArgumentError) do + OpenSSL::PKey::EC::Group.new(:GFp, 123) + end + + assert_equal("wrong number of arguments (given 2, expected 1 or 4)", e.message) + end + def test_ec_point group = OpenSSL::PKey::EC::Group.new("prime256v1") key = OpenSSL::PKey::EC.generate(group) |
