<HTML><BODY><br><br><br>-------- Пересылаемое сообщение --------<br>
От кого: Nikita Tatunov <n.tatunov@tarantool.org><br>
Кому: Vladislav Shpilevoy <v.shpilevoy@tarantool.org><br>
Копия: tarantool-patches@freelists.org, Alexander Turenko <alexander.turenko@tarantool.org><br>
Дата: Четверг,  9 августа 2018, 13:07 +03:00<br>
Тема: Re[2]: [PATCH] lua: add string.fromhex method<br>
<br>







<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div>
                <base target="_self" href="https://e.mail.ru/">
                
            <div id="style_15338092480000000310_BODY"><br>
Hello, Alexander, thnx for review!<br>
Vlad, could you please take a look?<br>
<br>
                                 >Четверг,  9 августа 2018, 10:06 +03:00 от Alexander Turenko < <a href="mailto:alexander.turenko@tarantool.org">alexander.turenko@tarantool.org</a> >:<br>
><br>
>Hi, Nikita!<br>
><br>
>The implementation LGTM.<br>
><br>
>See minor comments about the test below.<br>
><br>
>Please, proceed the next review round with Vlad.<br>
><br>
>WBR, Alexander Turenko.<br>
><br>
>On Wed, Aug 08, 2018 at 03:21:03PM +0300, N.Tatunov wrote:<br>
>> Add string.fromhex method. Add test for string.fromhex().<br>
>> <br>
>> Closes #2562<br>
>> ---<br>
>> <br>
>> Issue:  <a href="https://github.com/tarantool/tarantool/issues/2562" target="_blank">https://github.com/tarantool/tarantool/issues/2562</a><br>
>> Branch:  <a href="https://github.com/tarantool/tarantool/tree/N_Tatunov/gh-2562-fromhex-method" target="_blank">https://github.com/tarantool/tarantool/tree/N_Tatunov/gh-2562-fromhex-method</a><br>
>><br>
>> <...><br>
>><br>
>> diff --git a/test/app-tap/string.test.lua b/test/app-tap/string.test.lua<br>
>> index 1d10dcfc9..f88296fff 100755<br>
>> --- a/test/app-tap/string.test.lua<br>
>> +++ b/test/app-tap/string.test.lua<br>
>> @@ -3,7 +3,7 @@<br>
>>  local tap = require('tap')<br>
>>  local test = tap.test("string extensions")<br>
>> <br>
>> -test:plan(6)<br>
>> +test:plan(7)<br>
>> <br>
>>  test:test("split", function(test)<br>
>>      test:plan(10)<br>
>> @@ -114,6 +114,25 @@ test:test("hex", function(test)<br>
>>      test:is(string.hex(""), "", "hex empty string")<br>
>>  end)<br>
>> <br>
>> +test:test("fromhex", function(test)<br>
>> +    test:plan(11)<br>
>> +    test:is(string.fromhex("48656c6c6f"), "Hello", "from hex to bin")<br>
>> +    test:is(string.fromhex("4c696e7578"), "Linux", "from hex to bin")<br>
>> +    test:is(string.fromhex("6C6F72656D"), "lorem", "from hex to bin")<br>
>> +    test:is(string.fromhex("697073756D"), "ipsum", "from hex to bin")<br>
>> +    test:is(string.fromhex("6c6f72656d"), "lorem", "from hex to bin")<br>
>> +    test:is(string.fromhex("697073756d"), "ipsum", "from hex to bin")<br>
>> +    test:is(string.fromhex("6A6B6C6D6E6F"), "jklmno", "from hex to bin")<br>
>> +    test:is(string.fromhex("6a6b6c6d6e6f"), "jklmno", "from hex to bin")<br>
>> +    local _, err = pcall(string.fromhex, 'aaa')<br>
><br>
>Use double quotes when a file primarily uses this quotes type.<br>
><br>
      <br>
Fixed.<br>
<br>
>> +    test:ok(err and err:match("(even amount of chars expected," ..<br>
>> +                    " got odd amount)"), err)<br>
><br>
>1. Indent is strange (don't get what is the rule).<br>
>2. Don't use `err` for diagnostics (the message could can be unusable in case of an<br>
>   error).<br>
<br>
Didn't notice it, thnx.<br>
><br>
>> +    local _, err = pcall(string.fromhex, 'qq')<br>
><br>
>Single qutoes -> doule quotes.<br>
><br>
<br>
Fixed.<br>
<br>
>> +    test:ok(err and err:match("(hex string expected, got non hex chars)"), err)<br>
>> +    local _, err = pcall(string.fromhex, 795)<br>
>> +    test:ok(err and err:match("(string expected, got " .. type(795) .. ")"))<br>
><br>
>type(795) -> number<br>
><br>
<br>
Changed.<br>
<br>
>> +end)<br>
>> +<br>
>>  test:test("strip", function(test)<br>
>>      test:plan(6)<br>
>>      local str = "  hello hello "<br>
>> -- <br>
>> 2.15.2 (Apple Git-101.1)<br>
>> <br>
<br>
<br>
-- <br>
WBR, Nikita Tatunov.<br>
</div>
            
        
                <base target="_self" href="https://e.mail.ru/">
        </div>

        
</div>



<br><hr>
<br>-- <br>WBR, Nikita Tatunov.<br></BODY></HTML>