<commit_before>-- requires busted
-- busted lua_test/test.lua

dofile('test/stubs.lua')
dofile('src/handlers.lua')

describe("hex to rbg", function()

  it("should handle basic hex", function()

    local r,g,b = hextorgb('123456')
    assert.are.same(r, 18)
    assert.are.same(g, 52)
    assert.are.same(b, 86)

    local r,g,b = hextorgb('ffffff')
    assert.are.same(r, 255)
    assert.are.same(g, 255)
    assert.are.same(b, 255)

    local r,g,b = hextorgb('000000')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

  end)


  it("should handle different hex", function()

    local r,g,b = hextorgb('12345612345')
    assert.are.same(r, 18)
    assert.are.same(g, 52)
    assert.are.same(b, 86)

    -- not sure about values here, but mainly, it shouldn't crash
    local r,g,b = hextorgb('this is not a hex')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

    -- or here
    local r,g,b = hextorgb('0')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

  end)

end)


describe("message handling", function()

  it("should handle FILL messages", function()
    spy.on(buffer, "fill")

    handle_udp(nil, "FILL ff00cc", '', 0)
    assert.spy(buffer.fill).was_called_with(buffer,255,0,204)

    handle_udp(nil, "FILL 000000", '', 0)
    assert.spy(buffer.fill).was_called_with(buffer,0,0,0)
  end)


  it("should handle SET messages", function()
    spy.on(buffer, "set")

    handle_udp(nil, "SET ffffff 000000 ffffff cccccc", '', 0)
    assert.spy(buffer.set).was_called_with(buffer,1,255,255,255)
    assert.spy(buffer.set).was_called_with(buffer,2,0,0,0)
    assert.spy(buffer.set).was_called_with(buffer,3,255,255,255)
    assert.spy(buffer.set).was_called_with(buffer,3,204,204,204)

  end)

end)<commit_msg>Update test to new-style of SET<commit_after>-- requires busted
-- busted lua_test/test.lua

dofile('test/stubs.lua')
dofile('src/handlers.lua')

describe("hex to rbg", function()

  it("should handle basic hex", function()

    local r,g,b = hextorgb('123456')
    assert.are.same(r, 18)
    assert.are.same(g, 52)
    assert.are.same(b, 86)

    local r,g,b = hextorgb('ffffff')
    assert.are.same(r, 255)
    assert.are.same(g, 255)
    assert.are.same(b, 255)

    local r,g,b = hextorgb('000000')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

  end)


  it("should handle different hex", function()

    local r,g,b = hextorgb('12345612345')
    assert.are.same(r, 18)
    assert.are.same(g, 52)
    assert.are.same(b, 86)

    -- not sure about values here, but mainly, it shouldn't crash
    local r,g,b = hextorgb('this is not a hex')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

    -- or here
    local r,g,b = hextorgb('0')
    assert.are.same(r, 0)
    assert.are.same(g, 0)
    assert.are.same(b, 0)

  end)

end)


describe("message handling", function()

  it("should handle FILL messages", function()
    spy.on(buffer, "fill")

    handle_udp(nil, "FILL ff00cc", '', 0)
    assert.spy(buffer.fill).was_called_with(buffer,255,0,204)

    handle_udp(nil, "FILL 000000", '', 0)
    assert.spy(buffer.fill).was_called_with(buffer,0,0,0)
  end)


  it("should handle SET messages", function()
    spy.on(buffer, "set")

    local data = string.char(255,255,255, 0,0,0, 255,255,255, 204,204,204)

    handle_udp(nil, "SET " .. data, '', 0)
    assert.spy(buffer.set).was_called_with(buffer,1,data)

  end)

end)
{'fraction_non_alphanumeric': 0.16938017709225936, 'fraction_numerical': 0.06312482147957726, 'mean_word_length': 3.350310559006211, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3477037', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1390, 'n_words': 274}