describe('util', function()
  local util = require('wowless.util')
  describe('tget', function()
    local tget = util.tget
    it('works', function()
      assert.Nil(tget({}, 'foo'))
      assert.same(42, tget({ foo = 42 }, 'foo'))
      assert.Nil(tget({}, 'foo.bar'))
      assert.Nil(tget({ foo = {} }, 'foo.bar'))
      assert.same(42, tget({ foo = { bar = 42 } }, 'foo.bar'))
    end)
  end)
  describe('tset', function()
    local tset = util.tset
    it('works', function()
      assert.same({ foo = 42 }, tset({}, 'foo', 42))
      assert.same({ foo = { bar = 42 } }, tset({}, 'foo.bar', 42))
    end)
  end)
  describe('readfile', function()
    local readfile = util.readfile
    local path = require('path')
    it('reads filenames with no path parts', function()
      assert.Not.Nil(readfile('README.md'))
    end)
    it('reads relative paths', function()
      assert.Not.Nil(readfile('spec/wowless/util_spec.lua'))
    end)
    it('reads relative paths with dot slash', function()
      assert.Not.Nil(readfile('./././././README.md'))
    end)
    it('reads absolute paths', function()
      assert.Not.Nil(readfile(path.join(path.currentdir(), 'README.md')))
    end)
    it('reads filenames case insensitively', function()
      assert.Not.Nil(readfile('readme.md'))
    end)
    it('does not just stop at a good filename', function()
      assert.has.errors(function()
        readfile('README.md/foo')
      end)
    end)
  end)
end)
