mahoro.git  about / heads / tags
Ruby interface to libmagic
blob 6415afc91c67d980363960becd6e0c048063a8ca 768 bytes (raw)
$ git show v0.1:test.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
#!/usr/bin/env ruby

require 'test/unit'
require 'mahoro'

class MahoroTestCase < Test::Unit::TestCase

	def initialize(*args)
		super
		@m = Mahoro.new
	end

	def test_file
		@m.flags = Mahoro::NONE
		assert_equal('ASCII C program text', @m.file('mahoro.c'))
	end

	def test_mime_file
		@m.flags = Mahoro::MIME
		assert_equal('text/x-c; charset=us-ascii', @m.file('mahoro.c'))
	end

	def test_buffer
		@m.flags = Mahoro::NONE
		assert_equal('ASCII C program text',
		             @m.buffer(File.read('mahoro.c')))
	end

	def test_mime_buffer
		@m.flags = Mahoro::MIME
		assert_equal('text/x-c; charset=us-ascii',
		             @m.buffer(File.read('mahoro.c')))
	end

	def test_valid
		assert(@m.valid?, 'Default database was not valid.')
	end

end

# arch-tag: test

git clone https://yhbt.net/mahoro.git