File: winerror_spec.cr

package info (click to toggle)
crystal 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,384 kB
  • sloc: javascript: 6,400; sh: 695; makefile: 269; ansic: 121; python: 105; cpp: 77; xml: 32
file content (46 lines) | stat: -rw-r--r-- 1,324 bytes parent folder | download | duplicates (2)
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
require "spec"

describe WinError do
  it ".value" do
    {% if flag?(:win32) %}
      WinError.value = WinError::ERROR_SUCCESS
      WinError.value.should eq WinError::ERROR_SUCCESS
      WinError.value = WinError::ERROR_BROKEN_PIPE
      WinError.value.should eq WinError::ERROR_BROKEN_PIPE
    {% else %}
      expect_raises(NotImplementedError) do
        WinError.value = WinError::ERROR_SUCCESS
      end
      expect_raises(NotImplementedError) do
        WinError.value
      end
    {% end %}
  end

  it ".wsa_value" do
    {% if flag?(:win32) %}
      WinError.wsa_value = WinError::ERROR_SUCCESS
      WinError.wsa_value.should eq WinError::ERROR_SUCCESS
      WinError.wsa_value = WinError::WSAEBADF
      WinError.wsa_value.should eq WinError::WSAEBADF
    {% else %}
      expect_raises(NotImplementedError) do
        WinError.wsa_value = WinError::ERROR_SUCCESS
      end
      expect_raises(NotImplementedError) do
        WinError.wsa_value
      end
    {% end %}
  end

  it "#message" do
    message = WinError::ERROR_SUCCESS.message
    {% if flag?(:win32) %}
      # Not testing for specific content because the result is locale-specific
      # and currently the message uses only default `LANGID`.
      message.should_not be_empty
    {% else %}
      message.should eq ""
    {% end %}
  end
end