10000 Fix for #18 · openssl-net/openssl-net@97e6389 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 97e6389

Browse files
author
Frank Laub
committed
Fix for #18
1 parent e418349 commit 97e6389

File tree

4 files changed

+82
-10
lines changed

4 files changed

+82
-10
lines changed

ManagedOpenSsl/Core/Version.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,16 @@ public uint Fix
107107
/// <summary>
108108
/// Patch portion of the Version. These should start at 'a' and continue to 'z'.
109109
/// </summary>
110-
public char Patch
110+
public char? Patch
111111
{
112112
get
113113
{
114-
var patch = (raw & 0x00000ff0) >> 5;
114+
var patch = (raw & 0x00000ff0) >> 4;
115+
if (patch == 0)
116+
return null;
115117

116118
var a = Encoding.ASCII.GetBytes("a")[0];
117-
var x = a + patch;
119+
var x = a + (patch - 1);
118120
var ch = Encoding.ASCII.GetString(new[] { (byte)x })[0];
119121

120122
return ch;
@@ -161,12 +163,13 @@ public uint RawStatus
161163
/// <returns></returns>
162164
public override string ToString()
163165
{
164-
return string.Format("{0}.{1}.{2}{3} {4}",
166+
return string.Format("{0}.{1}.{2}{3} {4} (0x{5:x8})",
165167
Major,
166168
Minor,
167169
Fix,
168170
Patch,
169-
Status);
171+
Status,
172+
Raw);
170173
}
171174

172175
/// <summary>

ManagedOpenSsl/ManagedOpenSsl.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>9.0.30729</ProductVersion>
6+
<ProductVersion>8.0.30703</ProductVersion>
77
<SchemaVersion>2.0</SchemaVersion>
88
<ProjectGuid>{73DCC218-655B-485F-8EAC-0CE5F2F7343D}</ProjectGuid>
99
<OutputType>Library</OutputType>

test/TestVersion.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using NUnit.Framework;
3+
using OpenSSL.Core;
4+
using Version = OpenSSL.Core.Version;
5+
6+
namespace UnitTests
7+
{
8+
[TestFixture]
9+
public class TestVersion
10+
{
11+
[Test]
12+
public void Zero()
13+
{
14+
var version = new Version(0x00000000);
15+
Assert.AreEqual(0, version.Major);
16+
Assert.AreEqual(0, version.Minor);
17+
Assert.AreEqual(0, version.Fix);
18+
Assert.AreEqual(null, version.Patch);
19+
Assert.AreEqual(Version.StatusType.Development, version.Status);
20+
Assert.AreEqual(0, version.Raw);
21+
Assert.AreEqual("0.0.0 Development (0x00000000)", version.ToString());
22+
}
23+
24+
[Test]
25+
public void Basic1()
26+
{
27+
var version = new Version(0x102031af);
28+
Assert.AreEqual(1, version.Major);
29+
Assert.AreEqual(2, version.Minor);
30+
Assert.AreEqual(3, version.Fix);
31+
Assert.AreEqual('z', version.Patch);
32+
Assert.AreEqual(Version.StatusType.Release, version.Status);
33+
Assert.AreEqual(0x102031af, version.Raw);
34+
Assert.AreEqual("1.2.3z Release (0x102031af)", version.ToString());
35+
}
36+
37+
[Test]
38+
public void Basic2()
39+
{
40+
var version = new Version(0x1000200f);
41+
Assert.AreEqual(1, version.Major);
42+
Assert.AreEqual(0, version.Minor);
43+
Assert.AreEqual(2, version.Fix);
44+
Assert.AreEqual(null, version.Patch);
45+
Assert.AreEqual(Version.StatusType.Release, version.Status);
46+
Assert.AreEqual(0x1000200f, version.Raw);
47+
Assert.AreEqual("1.0.2 Release (0x1000200f)", version.ToString());
48+
}
49+
50+
[Test]
51+
public void Basic3()
52+
{
53+
var version = new Version(0x1000201f);
54+
Assert.AreEqual(1, version.Major);
55+
Assert.AreEqual(0, version.Minor);
56+
Assert.AreEqual(2, version.Fix);
57+
Assert.AreEqual('a', version.Patch);
58+
Assert.AreEqual(Version.StatusType.Release, version.Status);
59+
Assert.AreEqual(0x1000201f, version.Raw);
60+
Assert.AreEqual("1.0.2a Release (0x1000201f)", version.ToString());
61+
}
62+
}
63+
}
64+

test/UnitTests.csproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>9.0.30729</ProductVersion>
6+
<ProductVersion>8.0.30703</ProductVersion>
77
<SchemaVersion>2.0</SchemaVersion>
88
<ProjectGuid>{779FA0D7-D7CB-4408-A94D-B5718F118894}</ProjectGuid>
99
<OutputType>Library</OutputType>
@@ -43,6 +43,12 @@
4343
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
4444
<PlatformTarget>x86</PlatformTarget>
4545
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
46+
<EnvironmentVariables>
47+
<EnvironmentVariables>
48+
<Variable name="DYLD_LIBRARY_PATH" value="/usr/local/Cellar/openssl/1.0.2c/lib" />
49+
</EnvironmentVariables>
50+
</EnvironmentVariables>
51+
<ConsolePause>false</ConsolePause>
4652
</PropertyGroup>
4753
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4854
<DebugType>pdbonly</DebugType>
@@ -61,9 +67,7 @@
6167
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
6268
</Reference>
6369
<Reference Include="System" />
64-
<Reference Include="System.Core">
65-
<RequiredTargetFramework>3.5</RequiredTargetFramework>
66-
</Reference>
70+
<Reference Include="System.Core" />
6771
<Reference Include="System.Data" />
6872
<Reference Include="System.Xml" />
6973
</ItemGroup>
@@ -88,6 +92,7 @@
8892
<Compile Include="TestX509.cs" />
8993
<Compile Include="TestServer.cs" />
9094
<Compile Include="TestCipher.cs" />
95+
<Compile Include="TestVersion.cs" />
9196
</ItemGroup>
9297
<ItemGroup>
9398
<ProjectReference Include="..\ManagedOpenSsl\ManagedOpenSsl.csproj">

0 commit comments

Comments
 (0)
0