Skip to content

Commit c4ba85d

Browse files
authored
Merge pull request #7 from oxinabox/ox/seven
julia 0.7
2 parents 1770ace + 730c823 commit c4ba85d

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ os:
55
- linux
66
- osx
77
julia:
8-
- 0.6
8+
- 0.7
9+
- 1.0
910
- nightly
1011
notifications:
1112
email: false

REQUIRE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
julia 0.6
2-
SHA 0.5.3
1+
julia 0.7

appveyor.yml

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7-
8-
## uncomment the following lines to allow failures on nightly julia
9-
## (tests will run but not make your overall status red)
10-
#matrix:
11-
# allow_failures:
12-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
13-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
# # Uncomment the following lines to allow failures on nightly julia
12+
# # (tests will run but not make your overall status red)
13+
# matrix:
14+
# allow_failures:
15+
# - julia_version: nightly
1416

1517
branches:
1618
only:
@@ -24,24 +26,18 @@ notifications:
2426
on_build_status_changed: false
2527

2628
install:
27-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
28-
# If there's a newer build queued for the same PR, cancel this one
29-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
30-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
31-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
32-
throw "There are newer queued builds for this pull request, failing early." }
33-
# Download most recent Julia Windows binary
34-
- ps: (new-object net.webclient).DownloadFile(
35-
$env:JULIA_URL,
36-
"C:\projects\julia-binary.exe")
37-
# Run installer silently, output to C:\projects\julia
38-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3930

4031
build_script:
41-
# Need to convert from shallow to complete for Pkg.clone to work
42-
- IF EXIST .git\shallow (git fetch --unshallow)
43-
- C:\projects\julia\bin\julia -e "versioninfo();
44-
Pkg.clone(pwd(), \"MD5\"); Pkg.build(\"MD5\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4534

4635
test_script:
47-
- C:\projects\julia\bin\julia -e "Pkg.test(\"MD5\")"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
38+
39+
# # Uncomment to support code coverage upload. Should only be enabled for packages
40+
# # which would have coverage gaps without running on Windows
41+
# on_success:
42+
# - echo "%JL_CODECOV_SCRIPT%"
43+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

src/MD5.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module MD5
22

3-
# package code goes here
43

54
using SHA
65
using SHA: lrot, SHA_CTX
@@ -14,23 +13,23 @@ include("core.jl")
1413

1514

1615
# Our basic function is to process arrays of bytes
17-
function md5(data::T) where T<:Union{Array{UInt8,1},NTuple{N,UInt8} where N}
16+
function md5(data::T) where T<:Union{AbstractVector{UInt8}, NTuple{N,UInt8} where N}
1817
ctx = MD5_CTX()
1918
update!(ctx, data)
2019
return digest!(ctx)
2120
end
2221

2322

2423
# AbstractStrings are a pretty handy thing to be able to crunch through
25-
md5(str::AbstractString) = md5(Vector{UInt8}(str))
24+
md5(str::AbstractString) = md5(codeunits(str))
2625

2726
# Convenience function for IO devices, allows for things like:
2827
# open("test.txt") do f
2928
# sha256(f)
3029
# done
3130
function md5(io::IO, chunk_size=4*1024)
3231
ctx = MD5_CTX()
33-
buff = Vector{UInt8}(chunk_size)
32+
buff = Vector{UInt8}(undef, chunk_size)
3433
while !eof(io)
3534
num_read = readbytes!(io, buff)
3635
update!(ctx, buff[1:num_read])

test/nettle.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import Nettle
21
# redundant imports, so this file can be run standalone
3-
using Base.Test
2+
using Test
43
import MD5
4+
using Random
5+
6+
7+
import Nettle
8+
59

610
function test_equal_state(md5_value::MD5.MD5_CTX,nettle_value::Nettle.Hasher)
711
@test nettle_value.state[1:16] ==
@@ -33,3 +37,4 @@ end
3337
end
3438
end
3539
end
40+

test/runtests.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using MD5
2-
using Base.Test
2+
using Test
33

44
@testset "String Tests" begin
55
# From the reference https://tools.ietf.org/html/rfc1321 (final page)
@@ -14,18 +14,18 @@ using Base.Test
1414
end
1515

1616
@testset "Different forms of input data consistent" begin
17-
for len in [0,1,10,100,1000]
18-
bytearray = rand(UInt8, len)
19-
str = String(bytearray)
20-
stream = IOBuffer(bytearray)
21-
@test md5(bytearray) == md5(str)
17+
for len in [0,1,10, 100,1000]
18+
bytes = rand(UInt8, len)
19+
str = String(copy(bytes)) # String will take ownership and empty it's array inputs
20+
stream = IOBuffer(bytes)
21+
@test md5(bytes) == md5(str)
2222
@test md5(stream) == md5(str)
2323
end
2424
end
2525

2626
@testset "misc" begin
2727
@test MD5.digestlen(MD5.MD5_CTX) == length(md5(""))
28-
@test contains(sprint(show, MD5.MD5_CTX()), "MD5")
28+
@test occursin("MD5", sprint(show, MD5.MD5_CTX()))
2929
end
3030

3131
include("nettle.jl")

0 commit comments

Comments
 (0)