File: constants_spec.rb

package info (click to toggle)
dlr-languages 20090805%2Bgit.e6b28d27%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 51,484 kB
  • ctags: 59,257
  • sloc: cs: 298,829; ruby: 159,643; xml: 19,872; python: 2,820; yacc: 1,960; makefile: 96; sh: 65
file content (51 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
require File.dirname(__FILE__) + '/../../spec_helper'
require 'syslog'

describe "Syslog::Constants" do
  platform_is_not :windows do

    before :all do

    @constants = %w(LOG_AUTHPRIV LOG_USER LOG_LOCAL2 LOG_NOTICE LOG_NDELAY
                    LOG_SYSLOG LOG_ALERT LOG_FTP LOG_LOCAL5 LOG_ERR LOG_AUTH
                    LOG_LOCAL1 LOG_ODELAY LOG_NEWS LOG_DAEMON LOG_LOCAL4
                    LOG_CRIT LOG_INFO LOG_PERROR LOG_LOCAL0 LOG_CONS LOG_LPR
                    LOG_LOCAL7 LOG_WARNING LOG_CRON LOG_LOCAL3 LOG_EMERG
                    LOG_NOWAIT LOG_UUCP LOG_PID LOG_KERN LOG_MAIL LOG_LOCAL6
                    LOG_DEBUG)
    end

    it 'includes the Syslog constants' do
      @constants.each do |c|
        Syslog::Constants.constants.include?(c).should be_true
      end
    end

  end

  # The masks are defined in <syslog.h>

  describe "Syslog::Constants.LOG_MASK" do
    it "returns the mask value for a priority" do
      Syslog::Constants.LOG_MASK(Syslog::LOG_DEBUG).should == 128
      Syslog::Constants.LOG_MASK(Syslog::LOG_WARNING).should == 16
    end

    it "works on undefined constants" do
      Syslog::Constants.LOG_MASK(1337).should == 33554432
      Syslog::Constants.LOG_MASK(7331).should == 8
    end
  end

  describe "Syslog::Constants.LOG_UPTO" do
    it "returns a mask for the priorities up to a given argument" do
      Syslog::Constants.LOG_UPTO(Syslog::LOG_ALERT).should == 3
      Syslog::Constants.LOG_UPTO(Syslog::LOG_DEBUG).should == 255
    end

    it "works on undefined constants" do
      Syslog::Constants.LOG_UPTO(1337).should == 67108863
    end
  end
end